On Wed, Aug 16, 2017 at 11:00:43AM -0400, Yury Selivanov wrote: > "Context" is an established term for what PEP 550 tries to accomplish. > It's used in multiple languages and runtimes, and while researching > this topic I didn't see anybody confused with the concept on > StackOverflow/etc.
For me a context is a "single thing" that is usually used to thread state through functions. I guess I'd call "environment" what you call "context". > In C: > > PyContextItem * _current_ctx = PyContext_NewItem("decimal context"); > if (_current_ctx == NULL) { /* error */ } > > # later when you set decimal context > PyDecContextObject *ctx; > ... > if (PyContext_SetItem(_current_ctx, (PyObject*)ctx)) { /* error */ } > > # whenever you need to get the current context > PyDecContextObject *ctx = PyContext_GetItem(_current_ctx); > if (ctx == NULL) { /* error */ } > if (ctx == Py_None) { /* not initialized, nothing is there */ } Thanks! This makes it a lot clearer. I'd probably use (stealing Nick's key suggestion): PyEnvKey *_current_context_key = PyEnv_NewKey("___DECIMAL_CONTEXT__"); ... PyDecContextObject *ctx = PyEnv_GetItem(_current_ctx_key); Stefan Krah _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/