File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed
doc/source/reference/random Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change
1
+ Extending via CFFI
2
+ ------------------
3
+
4
+ .. literalinclude :: ../../../../../numpy/random/_examples/cffi/extending.py
5
+ :language: python
Original file line number Diff line number Diff line change @@ -49,6 +49,25 @@ RNG structure.
49
49
These functions along with a minimal setup file are included in the
50
50
`examples ` folder, ``numpy.random.examples ``.
51
51
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
+
52
71
New Basic RNGs
53
72
==============
54
73
`~Generator ` can be used with other user-provided BitGenerators. The simplest
@@ -85,3 +104,4 @@ Examples
85
104
Numba <examples/numba>
86
105
CFFI + Numba <examples/numba_cffi>
87
106
Cython <examples/cython/index>
107
+ CFFI <examples/cffi>
You can’t perform that action at this time.
0 commit comments