This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Claudiu.Popa
Recipients Arfrever, Claudiu.Popa, ncoghlan, serhiy.storchaka
Date 2013-12-13.12:40:40
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1386938441.08.0.94665488206.issue19385@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2013-12-13 12:40:41Claudiu.Popasetrecipients: + Claudiu.Popa, ncoghlan, Arfrever, serhiy.storchaka
2013-12-13 12:40:41Claudiu.Popasetmessageid: <1386938441.08.0.94665488206.issue19385@psf.upfronthosting.co.za>
2013-12-13 12:40:41Claudiu.Popalinkissue19385 messages
2013-12-13 12:40:40Claudiu.Popacreate