[Pyrex] Wrapping _randommodule.c
Simon Frost
sdfrost at ucsd.edu
Mon Oct 31 16:44:11 CET 2005
Dear Pyrex List,
I'd like to be able to access the internals of the RandomType object, as
defined in _randommodule.c, so I can generate random numbers within C code.
It's defined as follows:
typedef struct {
PyObject_HEAD
unsigned long state[N];
int index;
} RandomObject;
Random numbers are then generated using:
static PyObject * random_random(RandomObject *self);
What I would like to do is to generate a random number class generated
within Python
>> import random
>> rng=random.Random(1)
and then pass it to functions in Pyrex.
My questions are:
1. How do I link against _randommodule?
2. RandomObject is a struct containing a PyObject, which Pyrex doesn't
like. What's the usual workaround (except pass)?
3. How do I perform the type conversion which allows me to pass the
Python-generated object to random_random?
Thanks!
Simon
More information about the Pyrex
mailing list