[SciPy-dev] [SciPy-user] linspace

David M. Cooke cookedm at physics.mcmaster.ca
Tue Dec 6 06:12:52 EST 2005


Travis Oliphant <oliphant.travis at ieee.org> writes:

> David M. Cooke wrote:
>>Travis Oliphant <oliphant.travis at ieee.org> writes:
>>>David M. Cooke wrote:
>>>>I think the declarations in
>>>>scipy/base/code_generators/generate_array_api.py are out of sync with
>>>>current reality.
>>>>
>>>>
>>>Not the probelm but your solution would be nice anyway.
>>>
>>>
>>
>>Here's what I'm planning: Functions that are part of the API will look
>>like this in the scipy/base/src/files:
>>
>>/*OBJECT_API
>> A documentation string.
>>*/
>>static PyObject *
>>PyArray_SomeAPIFunction(...and it's arguments)
>>{
>>
>>generate_array_api.py will scan the source files, and generate the
>>appropiate objectapi_list and multiapi_list that are (right now)
>>assigned by hand in that file. To get the order, api functions will be
>>listed in files array_api_order.txt and multiarray_api_order.txt.
>>(The tag MULTIARRAY_API will be used for the multiarray API.)
>>
>>So, to add a new function: change the source file (in
>>scipy/base/src/whatever), and add the function name to the appropiate
>>place in the appropiate *_api_order.txt inside scipy/base/code_generators.

Ok, this is done and checked in.

>>Another thing I'm thinking about is using this to compute a hash of
>>the API, so extension modules can check that they're using the same
>>API as scipy. Putting this check into the import_array() macro would
>>mean that it'd be easier to track down those problems where the API's
>>changed, without the extension module being recompiled to match. It
>>could throw a warning much like Python when it tries to run something
>>compiled for an older C API.
>
> This sounds very, very good.

Not done yet, but much easier to add now. I'll add it later.

>>[Depending how much mondo magic you'd want, it'd be possible to store
>>a string representation of the API, and pinpoint precisely _where_ the
>>API changed between the extension module and scipy_core -- but I'll
>>leave that for another day.]
>>
> With an extra very if you can pull that off...

Looks good for this; I figure I'll #define a 32-bit constant
(determined from a hash of the return type, name, and argument types)
for each routine, and check it if the API hashes are not equal.

-- 
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke                      http://arbutus.physics.mcmaster.ca/dmc/
|cookedm at physics.mcmaster.ca




More information about the SciPy-Dev mailing list