[Numpy-discussion] Detecting C API mismatch (was Managing Python with NumPy and many external libraries on multiple Windows machines)
Charles R Harris
charlesr.harris at gmail.com
Sun May 10 12:55:46 EDT 2009
On Sun, May 10, 2009 at 10:13 AM, Charles R Harris <
charlesr.harris at gmail.com> wrote:
>
>
> On Sat, May 9, 2009 at 11:45 PM, David Cournapeau <cournape at gmail.com>wrote:
>
>> Hi,
>>
>> I worked on some code to detect C API mismatches both for developers
>> and for users:
>>
>> http://github.com/cournape/numpy/tree/runtime_feature
>>
>> It adds the following:
>> - if a numpy or ufunc function is added in the C API without the
>> NPY_FEATURE_VERSION to be updated, a warning is generated at built
>> time (the warning is turned into an exception for release)
>> - I added a function PyArray_GetNDArrayCFeatureVersion which returns
>> the C API version, and the version is checked in import_array. If the
>> compile-time version > import-time version, an import error is raised,
>> so the following happens (assuming the ABI is not changed).
>>
>> So we keep backward compatibility (building an extension with say
>> numpy 1.2.1 will still work after installing numpy 1.3), and forward
>> incompatibility is detected (building an extension with numpy 1.3.0
>> and importing it with installed numpy 1.2.1 will fail).
>>
>> Ironically, adding the function means that we have to add one function
>> to the C API, so this will not be useful for numpy < 1.4, but I don't
>> think it is possible to do it without modifying the C API.
>>
>
> Why not just use the current API to get the number? That looks easy to do,
> what is the problem? I'll fix it up if you want.
>
As you may have noticed, I really, really, don't like adding functions to
the API ;) Especially unneeded ones or ones that could be done at the python
level. So I think the thing to do here is split the version into two 16 bit
parts, then start with API version 0x000A and ABI version 0x0100 with the
version number being 0x01000009. There is nothing sacred about the numbers
as long as they remain ordered.
Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20090510/783f731b/attachment.html>
More information about the NumPy-Discussion
mailing list