[Numpy-discussion] Exposing experimental C-API for DTypes

Sebastian Berg sebastian at sipsolutions.net
Tue Mar 16 17:38:49 EDT 2021

Hi all,

For DTypes, it may soon make sense to expose API publicly for
testing/experimentation.  But, right now I don't really want to get
roped into discussing API details too much and slowing down potential
Do we have any idea for exposing an "experimental" API?

The first option would be "symbols" with an underscore in the name and
an understanding that using them might just break if you don't use the
exact version you wrote the code for and compiled with (i.e. no API/ABI
My current expectation is that everyone will be appalled by such a

For a single, simple project which would end up as a test, similar to
the `rational` tests, we could work in NumPy itself. That is fine, but
fairly strictly constrained...

Of course I can make a "branch" of NumPy that exports more API, but
that doesn't feel great either, it seems a bit clunky.

The last idea I have right now is a bit convoluted but safe: We add a
private python function:


and a corresponding header (potentially outside of NumPy).  The header
would include an:


macro/function that leverages the private "Python" function.  To import
the API (much like `import_array()` works).
Since it would use its own header, it could do strict version checks.
And since it would have to "ask numpy", NumPy could require an
environment variable to be set and/or print out a warning.

Am I missing some obvious solution?  Aside from "be patient and get it
right the first time"?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <https://mail.python.org/pipermail/numpy-discussion/attachments/20210316/51759b85/attachment.sig>

More information about the NumPy-Discussion mailing list