Message206069
Here's a benchmark:
- with current patch:
# ./python -S -m timeit -n 10000 -s 'import dbm.dumb as dbm; d=dbm.open("x.dat", "c");d.close()' 'try:' ' len(d)' 'except OSError:' ' pass'
10000 loops, best of 3: 1.78 usec per loop
- using
try:
return len(self._index)
except TypeError:
raise error('...')
# ./python -S -m timeit -n 10000 -s 'import dbm.dumb as dbm; d=dbm.open("x.dat", "c");d.close()' 'try:' ' len(d)' 'except OSError:' ' pass'
10000 loops, best of 3: 3.27 usec per loop
Now this seems odd, maybe catching + reraising an exception has a greater overhead than a func call and checking if an attribute is None. Anyway, I agree that dbm.dumb is not performance critical. |
|
Date |
User |
Action |
Args |
2013-12-13 12:40:41 | Claudiu.Popa | set | recipients:
+ Claudiu.Popa, ncoghlan, Arfrever, serhiy.storchaka |
2013-12-13 12:40:41 | Claudiu.Popa | set | messageid: <1386938441.08.0.94665488206.issue19385@psf.upfronthosting.co.za> |
2013-12-13 12:40:41 | Claudiu.Popa | link | issue19385 messages |
2013-12-13 12:40:40 | Claudiu.Popa | create | |
|