[Python-Dev] Using PEP384 Stable ABI for the lzma extension module

"Martin v. Löwis" martin at v.loewis.de
Tue Oct 4 19:39:52 CEST 2011


>> - Py_LIMITED_API is incompatible with --with-pydebug, and compilation stops.
>>   I skipped the check to continue.
>
> That seems like an odd (and undesirable) restriction.

It's deliberate, though.

> If different
> Python versions are going to expose the same ABI, it seems strange of
> debug and release versions can't do the same.

You'll have to specify a lot of details what precisely constitutes
a debug build, and what fields precisely belong to it. Nobody
volunteered to specify what it should do, so I excluded it. It's
also not the objective of the PEP to support loading debug-built
extensions in alternative interpreter versions.

I fail to see why this is undesirable, also. It's very easy to
write an extension module that only uses the limited API, and
still builds fine in a debug build: just don't define Py_LIMITED_API
when compiling for debug mode.

> The stable ABI probably needs a better solution for tp_new slots
> invoking tp_alloc and tp_dealloc slots invoking tp_free. In fact, a
> systematic review of the slot documentation is probably needed,
> pointing out the stable ABI alternatives to all of the recommended
> "cross slot" invocations (and creating them if they don't already
> exist).

Doing so would probably be better than my proposed approach of just
provding a generic access function that reads a slot as a void* from
a type object.

>> What do you think about using the stable ABI even in shipped extensions?
>
> It's probably not a bad idea, otherwise we may compilation without
> realising it. This is especially so for extension modules that *don't*
> need access to any of the interpreter internals.

Missing a word in the first sentence?

There is the xxlimited module that is there to test that it keeps
compiling under the limited API. I'll review all API additions
before the next release, and will exclude
a) anything that shouldn't be used by extension modules at all.
    There was a tradition of exposing all helper function, but
    I think this tradition needs to stop. Instead, adding to the
    API should be conservative, and only add what is positively
    useful to extension modules.
b) anything that is not sufficiently stable from the limited
    API (in particular stuff that refers to new structures).

The DLL .def file for Windows will make sure that nothing gets
added unintentionally to the stable ABI, unfortunately, there is
no easy technique for Unix achieving the same.

Regards,
Martin


More information about the Python-Dev mailing list