[Python-Dev] [Python-3000] Warning for 2.6 and greater

glyph at divmod.com glyph at divmod.com
Fri Jan 12 11:51:44 CET 2007


On 08:19 am, martin at v.loewis.de wrote:
>Georg Brandl schrieb:
>>> If Python 3.0 was simply a release which removed deprecated features,
>>> there would clearly be no issue. I would update my code in advance of
>>> the 3.0 release to not use any of those features being removed, and
>>> I'm all set. But that's not what I'm hearing. Python 3 is both adding
>>> new ways to do things, and removing the older way, in the same
>>> version, with no overlap. This makes me very anxious.
>>
>> It has always been planned that in those cases that allow it, the new way to do
>> it will be introduced in a 2.x release too, and the old way removed only in 3.x.
>
>What does that mean for the example James gave: if dict.items is going
>to be an iterator in 3.0, what 2.x version can make it return an
>iterator, when it currently returns a list?
>
>There simply can't be a 2.x version that *introduces* the new way, as it
>is not merely a new API, but a changed API.

The API isn't changed.  It's just dependent on its execution context in a confusing way.  That difference right now is being reflected as "2.x VM" vs. "3.0 VM" but there are other ways to reflect it more explicitly.  It would certainly be possible to have:

   from __future__ import items_is_iter

be the same as:

   __py3k_compat_items_is_iter__ = True

and have the 2.x series' items() method check the globals() of the calling scope to identify the return value of items() in that particular context.

If the actual data structures of module dictionaries and stack objects are too expensive there are other, similar things that could be done at the C level.  This implementation strategy is just the obvious thing that occurred to me after maybe 2 minutes of consideration.  I'm sure someone more familiar with the internals of Python could come up with something better.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20070112/b132759e/attachment-0001.htm 


More information about the Python-Dev mailing list