[Python-Dev] cpython: Rename contextlib.ignored() to contextlib.ignore(). (original) (raw)
Antoine Pitrou solipsis at pitrou.net
Wed Oct 16 14:09:16 CEST 2013
- Previous message: [Python-Dev] cpython: Rename contextlib.ignored() to contextlib.ignore().
- Next message: [Python-Dev] cpython: Rename contextlib.ignored() to contextlib.ignore().
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Le Wed, 16 Oct 2013 14:01:37 +0200, Victor Stinner <victor.stinner at gmail.com> a écrit :
2013/10/16 Antoine Pitrou <solipsis at pitrou.net>: >> By the way, what are the performances of contextlib.ignore()? >> Exceptions can be slow in some cases. Adding something even slower >> would not be a good idea. > > A "try" block which succeeds is fast.
Ah yes, I never reminder this fact. I try to not care too much of micro-optimizations :-)
It's not so much a micro-optimization than the fact that pushing a block on the stack is very cheap. IIRC, what is expensive is:
- creating the exception object with the associated traceback
- matching the exception in the "exception SomeException" clause
I don't have numbers, though :-)
Regards
Antoine.
- Previous message: [Python-Dev] cpython: Rename contextlib.ignored() to contextlib.ignore().
- Next message: [Python-Dev] cpython: Rename contextlib.ignored() to contextlib.ignore().
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]