Jan. 16, 2009
3:24 a.m.
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...
6445
Age (days ago)
6445
Last active (days ago)
0 comments
1 participants
participants (1)
-
Rodney Stephenson