◐ Shell
clean mode source ↗

bpo-42064: Move sqlite3 types to global state by erlend-aasland · Pull Request #26537 · python/cpython

Hmm, I'm not too familiar with the plan for the sqlite module.

Well... my plan is multi-phase init (which implies module state). Heap type conversion is done, and Argument Clinic is mostly in place; establishing a global state is a natural next step.

The calls to pysqlite_get_state(NULL) will be replaced with non-NULL in the future, right?

Correct. I could add a comment about that above pysqlite_get_state; those lines may look weird if that piece of information is missing.

EDIT: now I remember: grepping for pysqlite_get_state.NULL makes it easy to identify state lookups that need special care when we move from global to module state.

It seems that so far, the only module that uses dynamic types with Argument Clinic's subclass_of is _ssl, and AFAICS, it does things by walking the MRO twice. It might be worth it to add better support for this need. For example, I could imagine checking if any superclass was defined using a given PyType_Spec.

You're talking about a new API to optimise this, right?

EDIT: Yes, I see the twin clinic_state calls in the clinic files. That's unfortunate. _ssl solves this by adding a pointer to the state in the object state.