Re: [Python-Dev] map, filter, zip in future_builtins
On 18-Mar-08, at 6:01 PM, Benjamin Peterson wrote: Couldn't you just import imap as map? What do you mean? Import imap as map in future_builtins.c? Like the Python: import itertools map = intertools.map type(map(lambda x: x, range(3))) == map # True Ah, that's a much better idea :P I'll do that.___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] map, filter, zip in future_builtins
On 18-Mar-08, at 5:10 PM, Guido van Rossum wrote: > On Tue, Mar 18, 2008 at 3:54 PM, David Wolever > <[EMAIL PROTECTED]> wrote: > type(map(lambda x: x, [1, 2, 3])) # Python 2.6, with the patch >> > type(map(lambda x: x, [1, 2, 3])) == map >> False > Doesn't strike me as a terrible problem. Excellent, I'll go ahead and do the same thing with filter and zip. > Why is the latter == failing? What's the different between > type(map(...)) and map? Because future_builtins.map imports and returns itertools.imap: def map(*args): from itertools import imap return imap(*args) ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] map, filter, zip in future_builtins
On Tue, Mar 18, 2008 at 3:54 PM, David Wolever <[EMAIL PROTECTED]> wrote: > I'm working on #2171 -- putting map, filter, zip in 2.6's > future_builtins. > It has been suggested that it would be simplest to just return > itertools.(imap, izip, ifilter), which is what py3k/Python/ > bltinmodule.c, revision 61356 did. > > The advantage of this is that it's really easy and the behaviour > seems to be identical. > The disadvantage is that the two aren't identical: > >>> type(map(lambda x: x, [1, 2, 3])) # Python 3 > > >>> type(map(lambda x: x, [1, 2, 3])) == map > True > > >>> type(map(lambda x: x, [1, 2, 3])) # Python 2.6, with the patch > > >>> type(map(lambda x: x, [1, 2, 3])) == map > False > > Recommendations? Doesn't strike me as a terrible problem. Why is the latter == failing? What's the different between type(map(...)) and map? -- --Guido van Rossum (home page: http://www.python.org/~guido/) ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] map, filter, zip in future_builtins
I'm working on #2171 -- putting map, filter, zip in 2.6's future_builtins. It has been suggested that it would be simplest to just return itertools.(imap, izip, ifilter), which is what py3k/Python/ bltinmodule.c, revision 61356 did. The advantage of this is that it's really easy and the behaviour seems to be identical. The disadvantage is that the two aren't identical: >>> type(map(lambda x: x, [1, 2, 3])) # Python 3 >>> type(map(lambda x: x, [1, 2, 3])) == map True >>> type(map(lambda x: x, [1, 2, 3])) # Python 2.6, with the patch >>> type(map(lambda x: x, [1, 2, 3])) == map False Recommendations? ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com