[Python-Dev] [Python-3000] optimizing [x]range
Lisandro Dalcin
dalcinl at gmail.com
Sat Aug 4 01:44:23 CEST 2007
On 8/2/07, Stargaming <stargaming at gmail.com> wrote:
> >> made into an O(1) operation. here's a demo code (it should be trivial
> >> to implement this in CPython)
> [snipped algorithm]
Did you taked into account that your patch is not backward compatible
with py2.5?? Just try to do this with your patch,
$ python
Python 2.5.1 (r251:54863, Jun 1 2007, 12:15:26)
>>> class A:
... def __eq__(self, other):
... return other == 3
...
>>> A() in xrange(3)
False
>>> A() in xrange(4)
True
>>>
I know, my example is biased, but I have to insist. With this patch,
'a in xrange' will in general not be the same as 'a in range(...)'. I
am fine with this for py3k, but not sure if all people will agree on
this for python 2.6.
--
Lisandro Dalcín
---------------
Centro Internacional de Métodos Computacionales en Ingeniería (CIMEC)
Instituto de Desarrollo Tecnológico para la Industria Química (INTEC)
Consejo Nacional de Investigaciones Científicas y Técnicas (CONICET)
PTLC - Güemes 3450, (3000) Santa Fe, Argentina
Tel/Fax: +54-(0)342-451.1594
More information about the Python-Dev
mailing list