HARK designer 0.5.0 ドキュメント
Using Numpy C-API
コンテンツ
Using Numpy C-API
¶
How to extend NumPy
Writing an extension module
Required subroutine
Defining functions
Functions without keyword arguments
Functions with keyword arguments
Reference counting
Dealing with array objects
Converting an arbitrary sequence object
Creating a brand-new ndarray
Getting at ndarray memory and accessing elements of the ndarray
Example
Using Python as glue
Calling other compiled libraries from Python
Hand-generated wrappers
f2py
Creating source for a basic extension module
Creating a compiled extension module
Improving the basic interface
Inserting directives in Fortran source
A filtering example
Calling f2py from Python
Automatic extension module generation
Conclusion
weave
Speed up code involving arrays (also see scipy.numexpr)
Inline C-code
Simplify creation of an extension module
Conclusion
Pyrex
Pyrex-add
Pyrex-filter
Conclusion
ctypes
Having a shared library
Loading the shared library
Converting arguments
Calling the function
Complete example
Conclusion
Additional tools you may find useful
SWIG
SIP
Boost Python
Instant
PyInline
PyFort
Writing your own ufunc
Creating a new universal function
Example Non-ufunc extension
Example Numpy ufunc for one dtype
Example Numpy ufunc with multiple dtypes
Example Numpy ufunc with multiple arguments/return values
Example Numpy ufunc with structured array dtype arguments
PyUFunc_FromFuncAndData Specification
Beyond the Basics
Iterating over elements in the array
Basic Iteration
Iterating over all but one axis
Iterating over multiple arrays
Broadcasting over multiple arrays
User-defined data-types
Adding the new data-type
Registering a casting function
Registering coercion rules
Registering a ufunc loop
Subtyping the ndarray in C
Creating sub-types
Specific features of ndarray sub-typing
The __array_finalize__ method
The __array_priority__ attribute
The __array_wrap__ method
コンテンツ