[Alan Kennedy]
> On jython 2.1, I use something like this
> #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> try:
>   enumerate
> except NameError:
>   def enumerate(iterable):
>     results = [] ; ix = 0
>     for item in iterable:
>       results.append( (ix, item) )
>       ix = ix+1
>     return results

[Fredrik Lundh]
>> at least in CPython, using a user-defined enumerate function is a bit
>> slower than using the built-in version.

[Alan Kennedy]
>> Who's using a user-defined enumerate on cpython?

[Fredrik Lundh]
> anyone targeting older Python platforms.

You mean python platforms where there is no built-in enumerate?

Your comment makes "using a user-defined enumerate [on cpython] is
slower than using the built-in version" makes no sense in relation to
the code I posted, which only defines a user-defined enumerate *if
there is no builtin enumerate*.

[Alan Kennedy]
>> On cpython, the reference to enumerate doesn't generate a NameError,

[Fredrik Lundh]
>  > python
> Python 2.2.3 (#42, May 30 2003, 18:12:08)
>  >>> enumerate
> Traceback (most recent call last):
>    File "<stdin>", line 1, in ?
> NameError: name 'enumerate' is not defined

Right: there is no built-in enumerate on cpython 2.2. So how could a
user-defined one be slower than it?

Of course, my cpython comment referred to recent cpythons, i.e. 2.3,
2.4, 2.5. The code I supplied works on all versions of python, and
*never* replaces the built-in enumerate, if there is one.

So what's the problem, exactly?

regards,

--
alan kennedy
------------------------------------------------------
email alan:              http://xhaus.com/contact/alan

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to