This repository has been archived by the owner on Nov 21, 2022. It is now read-only.
Concerns about undefined behavior #149
Labels
needs more pep
An issue which needs to be documented in the PEP
rejected
A rejected idea
sc-feedback
Issues raised in the steering committee feedback
The PEP contains some pretty strong language (added fairly late in the process) that allows the compiler to use various optimizations (see "Performance considerations" and "Exceptions and side effects").
Some SC members don't seem happy with this. They are concerned about things like attributes implemented as properties with side effects, or
isinstance
operations with side effects. The PEP makes it undefined how many times such side effects occur, for example:Here we don't know how many times
MyClass
is looked up (some crazy side effect could switch the class object), and more importantly we allow but don't require the interpreter to cache the outcome ofisinstance(a, MyClass)
as well as the result ofa.x
anda.y
.I think the SC's concern is that once CPython has settled on a specific strategy here, whatever it does will become part of the de-facto standard that other implementations (e.g. PyPy) will have to implement, regardless of whether the PEP allows them more freedom.
I personally have a performance concern about a match statement with many
case SomeClass(...):
cases (each with a different class name) -- I wish there was some kind of pre-computation that could be done to turn this into a single (weak) dict lookup (possibly with a PyPy-style guard, and dynamically updating the dict as subclasses are encountered. But that would definitely be optional behavior.The text was updated successfully, but these errors were encountered: