8000 DOC: document the CFFI example · numpy/numpy@e0519fe · GitHub
[go: up one dir, main page]

Skip to content

Commit e0519fe

Browse files
committed
DOC: document the CFFI example
1 parent e4f2e11 commit e0519fe

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Extending via CFFI
2+
------------------
3+
4+
.. literalinclude:: ../../../../../numpy/random/_examples/cffi/extending.py
5+
:language: python

doc/source/reference/random/extending.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,25 @@ RNG structure.
4949
These functions along with a minimal setup file are included in the
5050
`examples` folder, ``numpy.random.examples``.
5151

52+
CFFI
53+
====
54+
55+
CFFI can be used to directly access the functions in
56+
``include/numpy/random/distributions.h``. Some "massaging" of the header
57+
file is required:
58+
59+
.. literalinclude:: ../../../../numpy/random/_examples/cffi/extending.py
60+
:language: python
61+
:end-before: dlopen
62+
63+
Once the header is parsed by ``ffi.cdef``, the functions can be accessed
64+
directly from the ``_generator`` shared object, using the `BitGenerator.cffi` interface.
65+
66+
.. literalinclude:: ../../../../numpy/random/_examples/cffi/extending.py
67+
:language: python
68+
:start-after: dlopen
69+
70+
5271
New Basic RNGs
5372
==============
5473
`~Generator` can be used with other user-provided BitGenerators. The simplest
@@ -85,3 +104,4 @@ Examples
85104
Numba <examples/numba>
86105
CFFI + Numba <examples/numba_cffi>
87106
Cython <examples/cython/index>
107+
CFFI <examples/cffi>

0 commit comments

Comments
 (0)
0