Conversation
…ation (:pep:`489`).
vstinner
left a comment
There was a problem hiding this comment.
I would prefer with a first short PR to prepare the work to just pass a state to UCD_Check(), without all other changes.
This PR is too big, I cannot review it. GitHub even hides the diff by default because it is too large :-D
|
I created https://bugs.python.org/issue41798 "meta-issue" to discuss the usage of the PyCapsule C API with multi-phase init API (PEP 489). |
That sounds like a good plan, to pass the module through a state. |
@vstinner Since the module state (which contains the capsule and a type) is new in this PR, it would be a struct with Most of the changes are breaking the functions (which are shared between the module and the type) into different entry points for either - so that I can get the module state from both flavors in the way that works for them. I propose to make the first stage just about this indirection, without switching to any heap types. What do you think? |
You can try to work in multiple steps (multiple PRs):
For the module state, it may be more flexible to pass ucnhash_CAPI to getname() and getcode() this API, rather than passing ucnhash_CAPI->module as the first parameter. |
|
@vstinner step 1 is equivalent to Are there any examples of heap types without module state that I can refer to? |
@vstinner This is definitely pythonic 👍 |

Second attempt, this time I'm slightly less ignorant about CPython core and argument clinic.
"Every problem in software engineering can be solved by adding a layer of indirection". I hope this is true about porting unicodedata to multi-phase init.
The challenge with this module is that the methods are shared between the module, class and in some cases a capsule API. Each of those cases will have its own way to get the module state (which is optional in the case of the capsule API).
I created internal functions like
unicodedata_UCD_normalize_internalwhich is passed in the module state. The class methods pass it in by getting it from the defining class, the module methods get it their own way.https://bugs.python.org/issue1635741