Hi Armin,
Indeed, this runs ahead of time --- maybe already at translation time, actually.
yes, but that's fine: the code has no side effects. If it does not run at translation time, the value of "gbl" seems to be frozen at its initial one, so that's not an option.
You can move this logic into a function _initialize_gbl(), and remove the appleveldefs entry for 'gbl'. Then call this new function at import time, by adding a method like this in the class Module in __init__.py: def startup(self, space): space.call_method(space.wrap(self), "_initialize_gbl")
That actually doesn't work: the translator complains about the setup of applevel objects being circular (don't have the exact error message handy). I've tried a range of variations, but no luck to get the desired outcome. But anyway after I decided to leave gbl as-is, and simply put the check in startup(), I found that it is run at program load, not on import, so that doesn't help in the first place. My current thinking is to weed the initialization down to the absolute minimum (that's a good thing regardless :) ), then fail on first use if the library is not available. Not ideal, but I guess in practice it makes little or no difference. Thanks, Wim -- wlavrij...@lbl.gov -- +1 (510) 486 6411 -- www.lavrijsen.net _______________________________________________ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev