[Python-Dev] limited_api and datetime

Nick Coghlan ncoghlan at gmail.com
Wed Aug 23 01:41:22 EDT 2017


On 23 August 2017 at 00:09, stackless <tismer at stackless.com> wrote:
> Hi again,
>
> I am trying to support the limited Api (PEP 384) for PySide. Fortunately,
> everything worked out of the box, just the datetime module gives me
> a problem. Inspection showed that datetime is completely removed
> when the limitation is set.
>
> Can somebody enlighten me why that needs to be so?

The main problem is that "datetime.h" defines several C structs that
we wouldn't want to add to the stable ABI, and nobody has previously
worked through details of the interface to see which parts of it could
still be used even if those structs were made opaque, and the macros
relying on them were switched to being functions instead.

There are almost certainly pieces of it that *could* be usefully
exposed, though.

> And how should I use datetime, instead: Fish the functions out of
> the dynamically imported datetime module?

Yep, going via the Python level API rather than directly to the C API
is the default answer, as that inherently hides any struct layout
details behind PyObject*.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia


More information about the Python-Dev mailing list