Meador Inge <mead...@gmail.com> added the comment:

Overall, this patch look reasonable.  I tested on py3k and the the tests pass.  
I also did a few micro-benchmarks to verify the speedup.  

One question I do have, though, is whether the 'len' calculation modifications 
are necessary?  This looks like an attempt to optimize more by taking advantage 
of a particular type's 'len' implementation, but in practice I am not sure it 
pays off.  In addition, it complicates the patch slightly.  I did the 
micro-benchmarks with the old 'len' calculation and the results where 
more-or-less the same as with the new 'len' calculation.  However, perhaps 
there are other cases where it would pay off that this simple micro-benchmark 
will not show.

# Micro-benchmarks
# python --with-pydebug
# OS X 10.6
# 2.26 GHz Core 2 Duo

# without patch
motherbrain:py3k minge$ ./python.exe -m timeit -s 'import array' 
"array.array('i', array.array('i', range(0, 10)))"
100000 loops, best of 3: 17.7 usec per loop
motherbrain:py3k minge$ ./python.exe -m timeit -s 'import array' 
"array.array('i', array.array('i', range(0, 100)))"
10000 loops, best of 3: 106 usec per loop
motherbrain:py3k minge$ ./python.exe -m timeit -s 'import array' 
"array.array('i', array.array('i', range(0, 1000)))"
1000 loops, best of 3: 1.57 msec per loop
motherbrain:py3k minge$ ./python.exe -m timeit -s 'import array' 
"array.array('i', array.array('i', range(0, 10000)))"
100 loops, best of 3: 17.4 msec per loop
motherbrain:py3k minge$ ./python.exe -m timeit -s 'import array' 
"array.array('i', array.array('i', range(0, 100000)))"
10 loops, best of 3: 178 msec per loop

# with patch
motherbrain:py3k minge$ ./python.exe -m timeit -s 'import array' 
"array.array('i', array.array('i', range(0, 10)))"
100000 loops, best of 3: 11.9 usec per loop
motherbrain:py3k minge$ ./python.exe -m timeit -s 'import array' 
"array.array('i', array.array('i', range(0, 100)))"
10000 loops, best of 3: 56.1 usec per loop
motherbrain:py3k minge$ ./python.exe -m timeit -s 'import array' 
"array.array('i', array.array('i', range(0, 1000)))"
1000 loops, best of 3: 785 usec per loop
motherbrain:py3k minge$ ./python.exe -m timeit -s 'import array' 
"array.array('i', array.array('i', range(0, 10000)))"
100 loops, best of 3: 8.69 msec per loop
motherbrain:py3k minge$ ./python.exe -m timeit -s 'import array' 
"array.array('i', array.array('i', range(0, 100000)))"
10 loops, best of 3: 88.7 msec per loop

# with patch, but 'len' mods removed
motherbrain:py3k minge$ ./python.exe -m timeit -s 'import array' 
"array.array('i', array.array('i', range(0, 10)))"
100000 loops, best of 3: 11.2 usec per loop
motherbrain:py3k minge$ ./python.exe -m timeit -s 'import array' 
"array.array('i', array.array('i', range(0, 100)))"
10000 loops, best of 3: 54.6 usec per loop
motherbrain:py3k minge$ ./python.exe -m timeit -s 'import array' 
"array.array('i', array.array('i', range(0, 1000)))"
1000 loops, best of 3: 782 usec per loop
motherbrain:py3k minge$ ./python.exe -m timeit -s 'import array' 
"array.array('i', array.array('i', range(0, 10000)))"
100 loops, best of 3: 8.66 msec per loop
motherbrain:py3k minge$ ./python.exe -m timeit -s 'import array' 
"array.array('i', array.array('i', range(0, 100000)))"
10 loops, best of 3: 88.3 msec per loop

----------
nosy: +meador.inge

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue5109>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to