Assignment Versus Equality
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Wed Jun 29 02:45:51 EDT 2016
On Wednesday 29 June 2016 15:51, Lawrence D’Oliveiro wrote:
> On Wednesday, June 29, 2016 at 5:26:46 PM UTC+12, Steven D'Aprano wrote:
>> BUT in Python 3, the distinction between int and long is gone by dropping
>> int and renaming long as "int". So all Python ints are BIGNUMs.
>
> I don’t understand what the problem is with this. Is there supposed to be
> some issue with performance? Because I can’t see it.
If there is a performance hit, it's probably pretty small. It may have been
bigger back in Python 3.0 or 3.1.
[steve at ando ~]$ python2.7 -m timeit -s "n = 0" "for i in xrange(10000): n += i"
100 loops, best of 3: 1.87 msec per loop
[steve at ando ~]$ python3.3 -m timeit -s "n = 0" "for i in range(10000): n += i"
1000 loops, best of 3: 1.89 msec per loop
Although setting debugging options does make it pretty slow:
[steve at ando ~]$ python/python-dev/3.6/python -m timeit -s "n = 0" "for i in
range(10000): n += i"
100 loops, best of 3: 13.7 msec per loop
--
Steve
More information about the Python-list
mailing list