[Python-ideas] User-defined literals

Guido van Rossum guido at python.org
Sat Jun 6 02:28:32 CEST 2015

On Thu, Jun 4, 2015 at 4:20 PM, Andrew Barnert <abarnert at yahoo.com> wrote:

> On Jun 4, 2015, at 14:05, Guido van Rossum <guido at python.org> wrote:
> OK, you can attribute that to lousy docs. The intention is that builtin
> types are immutable.
> I can go file bugs against those other implementations, but first, what's
> the rationale?
> The ABC PEP, the numbers PEP discussion, and the type/class unification
> tutorial all use the same reason: In CPython, different interpreters in the
> same memory space (as with mod_python) share the same built-in types. From
> the numbers discussion, it sounds like this was the only reason to reject
> the idea of just patching float.__bases__.
> But most other Python implementations don't have process-wide globals like
> that to worry about; patching int in one interpreter can't possibly affect
> any other interpreter.
> "Because CPython can't do it, nobody else should do it, to keep code
> portable" might be a good enough rationale for something this fundamental,
> but if that's not the one you're thinking of, I don't want to put those
> words in your mouth.

Why do you need a better rationale?

The builtins are shared between all modules in a way that other things
aren't. Nothing good can come from officially recognizing the ability to
monkey-patch the builtin types -- it would just lead to paranoia amongst
library developers.

--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150605/8076a6e6/attachment.html>

More information about the Python-ideas mailing list