Hrvoje Nikšić <hnik...@gmail.com> added the comment:

Thank you for your comments.

@Michael: I will of course write tests and documentation if there is indication 
that the feature will be accepted for stdlib.

@Antoine: it is true that a null context manager can be easily defined, but it 
does requires a separate generator definition, often repeated in different 
modules.  This is markedly less elegant than just using contextlib.null() in an 
expression.

I'm not acquainted with the history of identity function requests, but note 
that the identity function can be defined as an expression, using simply lambda 
x: x.  The equivalent expression that evaluates to a null context manager is 
markedly more convoluted, as shown in my report.

@Éric: The Null/_null/null distinction is an optimization that avoids creating 
new objects for something that is effectively a singleton.  It would be 
perfectly reasonable to define contextlib.null as Antoine did, but, this being 
stdlib, I wanted the implementation to be as efficient as (reasonably) possible.

----------

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

Reply via email to