[Python-Dev] [Python-3000] dict.items as attributes [Was: The bytes type]

Jim Jewett jimjjewett at gmail.com
Tue Jan 16 23:04:53 CET 2007


Other than dict.items (and .keys and .values) returning a non-list,
are there any other cases where the Py3K idiom can't already be used
in (or at least backported to) Py 2.x?

Is there a chance that this special case could be handled by an import
hook in py 2.6?

For example 2.6 could have an additional LOAD_ATTR_PY3 opcode that
just handles the special cases before delegating to the normal
LOAD_ATTR.

It would be generated instead of LOAD_ATTR whenever

    >>> from __future__ import py3

was in effect.

Supporting 2.5 (and 2.2) would be a bit harder, but I think the new
exception syntax would already require a py3->py2 translator, and
these three names still seem like a fairly simple transform.  So long
as the "real" source is kept in py3 format, autogenerating python 2
code shouldn't be much worse than autogenerating pyc files.

-jJ


More information about the Python-Dev mailing list