On Thu, Jun 6, 2019 at 5:20 PM Christoph Groth <christ...@grothesque.org> wrote: [..] > The other possibility I see would be wrapping ContextVar inside a class > (like in the example module that I attached to the first post in this > thread), but that's not a good solution. It requires replicating the > complete API, and is hence slow and not forward-compatible.
Wrapping isn't much slower than subclassing and calling super(). Indeed, you'll need to write some code that forwards calls to lower-level contextvars APIs, but that's fine. Enhancing contextvars with validators to satisfy your very specific use case would make contextvars slightly slower for all users that don't need that. I'm afraid that wrappers (composition) is the only way here. Yury _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/RAOWOA7DHU7SKN6O5HE2THUR3MZMUKV7/ Code of Conduct: http://python.org/psf/codeofconduct/