diff options
author | Pauli Virtanen <pav@iki.fi> | 2009-12-06 12:08:54 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2009-12-06 12:08:54 +0000 |
commit | 108960148ba8dd319a0b656158b8c7897fcf3307 (patch) | |
tree | 953d080951975fd9e50ba0f67449691e73f375c7 /numpy/random/mtrand/mtrand_py_helper.h | |
parent | 65b64fdf528ffae27054621b43ff78aa48b991b9 (diff) | |
download | numpy-108960148ba8dd319a0b656158b8c7897fcf3307.tar.gz |
3K: random: make mtrand to import
Diffstat (limited to 'numpy/random/mtrand/mtrand_py_helper.h')
-rw-r--r-- | numpy/random/mtrand/mtrand_py_helper.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/numpy/random/mtrand/mtrand_py_helper.h b/numpy/random/mtrand/mtrand_py_helper.h new file mode 100644 index 000000000..2e7e4b7dc --- /dev/null +++ b/numpy/random/mtrand/mtrand_py_helper.h @@ -0,0 +1,23 @@ +#ifndef _MTRAND_PY_HELPER_H_ +#define _MTRAND_PY_HELPER_H_ + +#include <Python.h> + +static PyObject *empty_py_bytes(unsigned long length, void **bytes) +{ + PyObject *b; +#if PY_MAJOR_VERSION >= 3 + b = PyBytes_FromStringAndSize(NULL, length); + if (b) { + *bytes = PyBytes_AS_STRING(b); + } +#else + b = PyString_FromStringAndSize(NULL, length); + if (b) { + *bytes = PyString_AS_STRING(b); + } +#endif + return b; +} + +#endif /* _MTRAND_PY_HELPER_H_ */ |