[Python-ideas] Make Python code read-only
Victor Stinner
victor.stinner at gmail.com
Tue May 20 22:32:25 CEST 2014
2014-05-20 19:37 GMT+02:00 Chris Angelico <rosuav at gmail.com>:
>> * The sys module cannot be made read-only because modifying sys.stdout
>> and sys.ps1 is a common use case.
>
> I think this highlights the biggest concern with defaulting to
> read-only.
Hum, maybe my email was unclear: the read-only mode is disabled by default.
When you enable the read-only mode, all modules are read-only except
the modules explicitly configured to be modifiable. I don't have a
strong opinion on this choice. We may only make modules read-only when
the read-only mode is activated and the module is explicitly
configured to be read-only.
Another option is to have a list of modules which should be made
read-only, configurable by the application.
> With that (rather big, and yet quite trivial) caveat, though: Looks
> interesting. Optimizing for the >99% of code that doesn't do weird
> things makes very good sense, just as long as the <1% can be catered
> for.
Yeah, the whole stdlib doesn't need to be read-only to make an
application faster.
Victor
More information about the Python-ideas
mailing list