[Python-Dev] PEP 550 v4
Ethan Furman
ethan at stoneleaf.us
Thu Sep 7 09:25:22 EDT 2017
On 09/06/2017 11:57 PM, Yury Selivanov wrote:
> On Wed, Sep 6, 2017 at 11:39 PM, Greg Ewing wrote:
>> Here's one way that refactoring could trip you up.
>> Start with this:
>>
>> async def foo():
>> calculate_something()
>> #in a coroutine, so we can be lazy and not use a cm
>
> Where exactly does PEP 550 encourage users to be "lazy and not use a
> cm"? PEP 550 provides a mechanism for implementing context managers!
> What is this example supposed to show?
That using a CM is not required, and tracking down a bug caused by not using a CM can be difficult.
> How is PEP 550 is at fault of somebody being lazy and not using a
> context manager?
Because PEP 550 makes a CM unnecessary in the simple (common?) case, hiding the need for a CM in not-so-simple cases.
For comparison: in Python 3 we are now warned about files that have been left open (because explicitly closing files was
unnecessary in CPython due to an implementation detail) -- the solution? make files context managers whose __exit__
closes the file.
> PEP 550 has a hard requirement to make it possible for decimal/other
> libraries to start using its APIs and stay backwards compatible, so it
> allows `decimal.setcontext(ctx)` function to be implemented. We are
> fixing things here.
I appreciate that the scientific and number-crunching communities have been a major driver of enhancements for Python
(such as rich comparisons and, more recently, matrix operators), but I don't think an enhancement for them that makes
life more difficult for the rest is a net win.
--
~Ethan~
More information about the Python-Dev
mailing list