Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add PEP 489 support #209

Open
wants to merge 78 commits into
base: master
Choose a base branch
from
Open

feat: add PEP 489 support #209

wants to merge 78 commits into from

Conversation

tseaver
Copy link
Member

@tseaver tseaver commented Jun 5, 2024

This PR sits atop #208. You might find easier just to review this one, even though it is huge.

tseaver added 30 commits June 2, 2024 23:57
It is initialized with what turns out to be '&PyBaseObject_Type', which
we can just use as is.
Note that we aren't storing it on the module state record yet, as that
triggers segfaults.
Requires overriding all the macros from 'cPersistence.h', most of which
(irony, anyone?) exist only for our benefit.
Prep for heap-allocating them.
- Use consistent naming, w/ '_type_def' suffix (for easy comparison
  with forthcoming '_type_spec' for heap-allocated types).

- Use named members, removing clutter.

- Move protocol specs (number, sequence, mepping) next to type definitions,
  to ease constructino of equivalent '_type_slots' for heap-allocated types.

- Add TODOs to locations outside module initialization which use the
  addresses of type defs:  they need to look them up on the module state.
Verses addresses of the static type defs.
Avoid segfault at application exit.
tseaver added 28 commits June 4, 2024 21:46
Avoids 'PyObject_New' FBO heap-allocated types, but works just as
well for the statid types.
And use its 'tp_alloc' slot, rather than calling it as an object.
Both faster and easier to reason about.

One exception is the call to create a new bucket for a tree, which
has to live with the promise made to respect the '_bucket_type' attribute
on derived classes.
Heap-allocated BTrees et. all still segfault.
Use static inlined versions, to placate compilers which don't allow
'foreign' function pointers in static initializers.
Their arguments cannot be guaranteed to be instances of our types,
which means we cannot use them to dead-reckon to the module.

All callers have, or can easily derive, the module anyway.
Ensure that we play nicely with 'Persistent', whether it is heap-allocated
or no.
Rather than dead-reckoning from types of args, make callers pass in
the module (they probably have it already at this point).
In prepration for dropping the others and renaming the '_from_module' ones
Takes either a module or a BTree-ish object, and returns the PerCAPI*.

Will replace both '_get_capi_struct' and '_get_capi_struct_from_module'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant