[Python-Dev] cpython (3.2): don't mention implementation detail

Maciej Fijalkowski fijall at gmail.com
Tue Dec 20 21:22:04 CET 2011

On Tue, Dec 20, 2011 at 12:14 PM, Dirkjan Ochtman <dirkjan at ochtman.nl> wrote:
> On Tue, Dec 20, 2011 at 11:08, Antoine Pitrou <solipsis at pitrou.net> wrote:
>>> If this documentation is to be used by other python implementations,
>>> then mentions of performance are outright harmful, since the
>>> performance characteristics differ quite drastically. Written in C is
>>> also not a part of specification as far as I know :)
>> But that's basically the only reason to invoke the
>> `operator.attrgetter("foo")` ugliness, instead of writing the explicit
>> and obvious `lambda x: x.foo`.
>> So not mentioning that it provides a speed benefit on CPython hides the
>> primary reason for using the operator module. Overwise it's just a bunch
>> of useless wrappers.
> So the question is if the docs are Python documentation or CPython
> documentation? On PyPy, I'm guessing lambda x: x.foo might (some day)
> be just as fast as operator.attrgetter("foo").

as of now lambda is much faster on pypy for a constant name (there is
not a good reason why exactly attrgetter is slower, but it somehow
losts the fact that name is constant if it is).

I'm in general fine with saying that this is either Python
documentation or CPython documentation, but leaving this intermingled
has caused us quite some headaches in the past. For example using
attrgetter and map rather than just writing a loop is slower on PyPy,
so a knowledge that it's *fast* in the operator module is misleading
*in Python*. How about we somehow mark that all python documentation
when it talks about performance, it talks about CPython performance?


More information about the Python-Dev mailing list