[pypy-dev] RPython Environment Variables
Amaury Forgeot d'Arc
amauryfa at gmail.com
Fri Nov 1 01:16:01 CET 2013
2013/11/1 Ryan Gonzalez <rymg19 at gmail.com>
> I am writing a tool in RPython that needs to access environment variables.
> Now, all has been going well, but I noticed something interesting. The
> RPython translator sees os.environ as constant. But, will it still be
> constant on other platforms?
>
> What I'm saying is, are the environment variables permanently embedded
> into the application? i.e., if I run it on another PC, the values will be
> the same? Or is there an RLib equivalent? Because I really don't feel like
> writing a C wrapper...
>
RPython magic...
In RPython, os.environ is not a dictionary, but a clever wrapper around
getenv() and putenv().
See the implementation in ll_os_environ.py:
https://bitbucket.org/pypy/pypy/src/default/rpython/rtyper/module/ll_os_environ.py
- as an object, os.environ is equivalent to None: nothing is embedded in
the application.
- only some methods are implemented, and redirect to some implementation
that use the C primitives.
Yes, I also found this "Controller" crazy the first time I saw it. But very
clever and powerful.
--
Amaury Forgeot d'Arc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20131101/ef6f5a9c/attachment.html>
More information about the pypy-dev
mailing list