[Python-ideas] Make Python code read-only

Victor Stinner victor.stinner at gmail.com
Thu May 22 01:22:49 CEST 2014


2014-05-21 3:42 GMT+02:00 Steven D'Aprano <steve at pearwood.info>:
> - Obviously the "best" (most obvious) solution would be if there was a
> way to unlock modules on the fly, but Victor suggests that's hard.

The problem is to react to such event. In a function has a specialized
version for a set of read-only objects, the specialized version should
not be used anymore.

Ok, I create a new branch "readonly_cb" branch where it is possible to
make again modules, types and functions modifiable. *But* when the
readonly state is modified, a callback is called. It can be used to
disable optimizations relying on it. So all issues listed in this
thread are away. It's possible again to use monkey-patching, lazy
initialization of module variables and class variables, etc.

I hope that such callback is enough to make optimizations efficient.

Victor


More information about the Python-ideas mailing list