Skip to content
murmot

Results for “function return python array java code c++ example file site:numpy.org program”

  • numpy.org

    Array API — NumPy v2.6.dev0 Manual

    For the typical Python project, multiple C or C++ files will be compiled into a single shared object (the Python C-module) and PyArray_ImportNumPyAPI() should be called inside it’s module initialization. When you have a single C-file, this will consist of

  • numpy.org

    How to extend NumPy — NumPy v1.16 Manual

    The following example shows how you might write a wrapper that accepts two input arguments (that will be converted to an array) and an output argument (that must be an array). The function returns None and updates the output array.

  • numpy.org

    How to extend NumPy — NumPy v2.5 Manual

    The mymethods must be an array (usually statically declared) of PyMethodDef structures which contain method names, actual C-functions, a variable indicating whether the method uses keyword arguments or not, and docstrings. These are explained in the next section. If you want to add constants to the module, then you store the returned value from Py_InitModule which is a module object. The most ...

  • numpy.org

    How to extend NumPy — NumPy v2.6.dev0 Manual

    import_array(); return PyModule_Create(&moduledef); } The mymethods must be an array (usually statically declared) of PyMethodDef structures which contain method names, actual C-functions, a variable indicating whether the method uses keyword arguments or not, and docstrings.

  • numpy.org

    Writing your own ufunc — NumPy v2.5 Manual

    To create the module, one proceeds as one would for a Python package, creating a pyproject.toml file, which defines a build back-end, and then another file for that backend which describes how to compile the code. For the backend, we recommend meson-python, as we use it for numpy itself, but below we also show how to use the older setuptools.

  • numpy.org

    Array API — NumPy v1.17 Manual

    Returns an ndarray object from a Python object that exposes the __array_struct__ attribute and follows the array interface protocol. If the object does not contain this attribute then a borrowed reference to Py_NotImplemented is returned.

  • numpy.org

    Using Python as glue — NumPy v2.6.dev0 Manual

    Here is an example of how to set up a Python project that contains a Cython extension. The example uses the meson-python Python build backend and the meson build system. This is the same build system NumPy itself uses. . First, create a file named my_extension.pyx.

  • numpy.org

    Python types and C-structures — NumPy v2.5 Manual

    Python types and C-structures # Several new types are defined in the C-code. Most of these are accessible from Python, but a few are not exposed due to their limited use. Every new Python type has an associated PyObject* with an internal structure that includes a pointer to a “method table” that defines how the new object behaves in Python.

  • numpy.org

    Using Python as glue — NumPy v2.5 Manual

    There are two basic approaches to calling compiled code: writing an extension module that is then imported to Python using the import command, or calling a shared-library subroutine directly from Python using the ctypes module. Writing an extension module is the most common method.