2008/10/8 "Martin v. Löwis" <[EMAIL PROTECTED]>:
>> How is this supposed to work?
>
> The design was that you use PyState_FindModule, as an efficient way for
> getting a module object if you have the module def. The implementation
> fills an index into the module def (which will stay constant across
> interpreters), this this should give you your module object anywhere,
> in constant time.

This is exactly what I was looking for. Thanks!

> If you have specific proposals on how to make this more convenient to
> use, please go ahead. (also, if you think that this somehow flawed:
> this would be the time to mention it)

I suppose that common usage will do things like this:
    ((MyModuleState
*)PyModule_GetState(PyState_FindModule(&myModuleDef)))->globalValue
If you want to check for errors, it becomes tedious and some kind of
macro could be useful.
But this can be added later.

Why is the function caller PyState_FindModule? It's the only one with
this prefix (with _PyState_AddModule); other functions in the same
module are called PyInterpreterState_*. I suggest to rename it now;
otherwise there may be confusion between "module state" and
"interpreter state"; see the example above:
PyModule_GetState(PyState_FindModule(x)) seems to be a round-trip (or
a no-op) to the casual reader.

And unless you already planned to do so, I think I will start to
document the module API.

-- 
Amaury Forgeot d'Arc
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to