On Fri, Mar 18, 2022 at 9:40 AM Paul Bryan <[email protected]> wrote:
On Fri, 2022年03月18日 at 09:35 -0700, Guido van Rossum wrote:
The motivation has been explained already.
In this thread?
Yes, Eric's message.
What on earth did your test do that got a speedup by using sets?
Was it repeatedly checking whether a variable was in a slot? The
other thing this does is rearrange the order in which slots
appear from run to run (since set order is affected by hash
randomization) and you might have gotten lucky with a popular
attribute being moved to the front, where it's more likely to be
in the memory cache already (cache lines being 64 bytes and
pointers being 8 bytes nowadays).
I created objects in a tight loop, populating attributes, noting
the elapsed time.
It does not make sense that that is correlated to the type of
__slots__, since __slots__ is not used for instance creation at all
(it is only used to create the class). I stick to my likely explanation.
Regarding Serhiy's proposal, I'm +0 on disallowing strings, and +0 on
disallowing things that can't be reiterated (but it's not a problem in
practice). Given other responses the status quo is likely best.