py3k concerns. An example

Kay Schluehr kay.schluehr at gmx.net
Fri Apr 18 16:17:32 EDT 2008


On 18 Apr., 20:07, Aaron Watters <aaron.watt... at gmail.com> wrote:

> I don't really know, but I think "fixing" the above issue for
> string.format(...) might involve changing the representation of
> every python stack frame... not worth it in this case if there
> is any penalty (afaik there isn't).

In Python 2.6 the format function simply calls PyDict_GetItem on the
dictionary object and raises a KeyError if it fails. A dict emulation
would require one more lookup if the fast lookup has no result. It
would be a speed penalty in the general case if this lookup would be
implemented in PyDict_GetItem but handling a special case in the
format implementation might not look that bad.




More information about the Python-list mailing list