[Python-ideas] Make Python code read-only

Nick Coghlan ncoghlan at gmail.com
Wed May 21 11:43:05 CEST 2014


On 21 May 2014 11:48, "Steven D'Aprano" <steve at pearwood.info> wrote:
>
> On Wed, May 21, 2014 at 03:37:42AM +1000, Chris Angelico wrote:
>
> > 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.
>
> "99% of Python code doesn't do weird things..."
>
> It seems to me that this is a myth, or at least unjustifiable by the
> facts as we have seen it. Victor's experiment shows 25 modules from the
> standard library are modifiable, with 139 read-only. That's more like
> 15% than 1% "weird".

It also misses the big reason I am a Python programmer rather than a Java
programmer.

For me, Python is primarily an orchestration language. It is the language
for the code that is telling everything else what to do. If my Python code
is an overall performance bottleneck, then "Huzzah!", as it means I have
finally engineered all the other structural bottlenecks out of the system.

For this use case, monkey patching is not an incidental feature to be
tolerated merely for backwards compatibility reasons: it is a key
capability that makes Python an ideal language for me, as it takes ultimate
control of what dependencies do away from the original author and places it
in my hands as the system integrator. This is a dangerous power, not to be
used lightly, but it also grants me the ability to work around critical
bugs in dependencies at run time, rather than having to fork and patch the
source the way Java developers tend to do.

Victor's proposal is to make Python more complicated and a worse
orchestration language, for the sake of making it a better applications
programming language. In isolation, it might be possible to make that case,
but in the presence of PyPy for a full dynamically optimised runtime and
tools like Cython and Numba for selective optimisation within CPython, no.

Regards,
Nick.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20140521/eeffd3e7/attachment.html>


More information about the Python-ideas mailing list