[Python-Dev] Using PEP384 Stable ABI for the lzma extension module (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Tue Oct 4 19:05:58 CEST 2011
- Previous message: [Python-Dev] Using PEP384 Stable ABI for the lzma extension module
- Next message: [Python-Dev] Using PEP384 Stable ABI for the lzma extension module
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
(My comments are based on the assumption Amaury started with http://hg.python.org/sandbox/nvawda/file/09d984063fca/Modules/_lzmamodule.c)
On Tue, Oct 4, 2011 at 12:18 PM, Amaury Forgeot d'Arc <amauryfa at gmail.com> wrote:
- PyLIMITEDAPI is incompatible with --with-pydebug, and compilation stops. I skipped the check to continue.
That seems like an odd (and undesirable) restriction. If different Python versions are going to expose the same ABI, it seems strange of debug and release versions can't do the same.
- I replaced PyBytesGETSIZE() with PySIZE(), which is OK, and PyBytesASSTRING() with PyBytesAsString(), which may have a slight performance impact.
Yes, the price of using the stable ABI is that performance tricks that depend on exact memory layouts are no longer available.
- I replaced PyTYPE(self)->tpfree((PyObject *)self); with PyObjectDel(self), I hope this is the same thing (for a non-GC object)
That looks right in this particular case, but problematic in general.
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).
- PyBytesResize() is missing; I moved it under a PyLIMITEDAPI section.
No, that's not valid. Bytes are officially immutable - mutating them when the reference count is only 1 is a private for a reason. The correct way to do this without relying on that implementation detail is to use a byte array instead.
- For the "y*" argument spec, the Pybuffer structure is required (only for two fields: buf and len), as well as PyBufferRelease()
Yeah, PEP 3118 support will eventually appear in the stable ABI, but we need to fix it first (see issue 10181).
- PyTypeFromSpec() does not call PyTypeReady(), which caused crashes in new.
That sounds like it may just be a bug.
Although looking at the C API docs, PEP 384 documentation appears to be basically non-existent...
Now the module seems to work correctly and passes tests... at least on Linux in a standard environment. I will do other tests on Windows.
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.
Cheers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-Dev] Using PEP384 Stable ABI for the lzma extension module
- Next message: [Python-Dev] Using PEP384 Stable ABI for the lzma extension module
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]