There was some recent discussion about the (inefficiency) of 'in' when
applied to a large xrange. I was wondering how numpy handled this and
found the following

    >>> from numpy import *
    >>> u = arange(2**26)
    >>> 2**24 in u
    True
    >>> 2**31 in u
    False
    >>> 2**32 in u
    True

Hmmmm...

    >>> u = arange(10, 2**26)
    >>> 1 in u
    False
    >>> 2**37 in u
    False
    >>> 0 in u
    False
    >>> u[0]=0
    >>> 2**37 in u
    True
    >>> 

So I presume that in casting the long to int for the test is done by 
just taking the last 32 bits! Bug or feature? Python silently turns 
ints to longs when they overflow, so one should be careful...

_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to