[Python-Dev] PEP 567 v2 (original) (raw)
Victor Stinner victor.stinner at gmail.com
Wed Jan 3 12:37:38 EST 2018
- Previous message (by thread): [Python-Dev] PEP 567 v2
- Next message (by thread): [Python-Dev] PEP 567 v2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Victor:
ContextVar would be simpler if the default would be mandatory as well :-)
If we modify ContextVar to use None as the default value, the 'default' parameter of ContextVar.get() becomes useless, ContextVar.get() and context[var] behaviour becomes obvious. Token.MISSING could also be removed.
Since it's not possible to delete a variable, would it be crazy to always initialize variables with a value, None by default?
Decimal context is given as an example of contextvars user. Decimal already has a default context. I don't know numpy.errstate: would it make sense to initialize it to None?
If someone really needs the crazy case of "uninitialized" variable, a custom "UNINITIALIZED = object()" can be used, no?
With these proposed changes, there is no more need to worry if a variable is set or not.
It's unclear to me if context.items() contains variables which weren't explicit set, and so are set to their default value. Same question for "var in context" test. If variables always have a value, I would expect that "var in context" is always true but I don't understand if it's technically possible to implement it or even if it makes sense :-)
Maybe my whole proposed change doesn't make sense?
Victor -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20180103/050e0147/attachment.html>
- Previous message (by thread): [Python-Dev] PEP 567 v2
- Next message (by thread): [Python-Dev] PEP 567 v2
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]