GeezerVison is showing github.com — Isolate _multibytecodec · Issue #103583 · python/cpython
Isolate _multibytecodec #103583Activitychanged the title [-]isolate _multibytecodec[/-] [+]Isolate _multibytecodec[/+] on Apr 16, 2023erlend-aasland commented on Apr 16, 2023 ContributorAuthor More actions In gh-103540 I've isolated _multibytecodec. However, more steps are needed to isolate the _codec_* (sub-ish) modules. I've identified some issues that IMO should be solved first, preferably in separate PRs:
- There is no reference dependency between the _multibytecodec and the _codecs_* modules. This is a problem, because the MultibyteCodecObject type (of the _multibytecodec module) stores pointers to codec structs whose memory is owned by the _codecs_* modules. IMO, this needs to be done anyway, so we can start here.
- There are two types of capsules used (one for maps, one for codecs), but both of them use the same name. IMO, this is both confusing and fragile. I suggest to use distinct names instead.
- We need a way to store global pointers to codecs and maps; one possibility is to expand the
MultibyteCodec struct and pass that to the various mb handlers. Another possibility is to store these in _codecs_* module state, store that state, for example in MultibyteCodecObject, and pass state to the mb handlers. Yet another possibility is to use the config member of MultibyteCodec for this, and change the semantics of that struct field.
Also, some low-hanging fruit that IMO can be done right now:
- We've got both
MultibyteCodec_State and _multibytecodec_state. IMO, we should rename one of those; the current naming is too similar and confusing.
MultibyteCodec pointers should be passed as const
erlend-aasland commented on Apr 16, 2023 ContributorAuthor More actions erlend-aasland commented on Apr 16, 2023 ContributorAuthor More actions
In gh-103540 I've isolated _multibytecodec.
No, I haven't; I've only put the codec and map arrays into the _codecs* module state. erlend-aasland commented on Apr 26, 2023 ContributorAuthor More actions @corona10, I made three competing PRs for how to implement custom module state for the CJK modules. IMO, alternative 2 is the best approach. Alt 3 is way too complex (and currently, it does not even work). Alt 1 is too hacky.
cc. @kumaraditya303 corona10 commented on Apr 26, 2023
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|