Message118189
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. |
|
Date |
User |
Action |
Args |
2010-10-08 11:52:04 | hniksic | set | recipients:
+ hniksic, ncoghlan, pitrou, vstinner, eric.araujo, michael.foord |
2010-10-08 11:52:04 | hniksic | set | messageid: <1286538724.86.0.251036544124.issue10049@psf.upfronthosting.co.za> |
2010-10-08 11:52:03 | hniksic | link | issue10049 messages |
2010-10-08 11:52:02 | hniksic | create | |
|