On 3/18/2022 4:58 PM, Guido van Rossum wrote:
On Fri, Mar 18, 2022 at 9:40 AM Paul Bryan <pbr...@anode.ca> 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.
The PR for the issue I mentioned (https://bugs.python.org/issue46382)
allows strings and iterables (but not iterators). And it uses a match
statement, no less! I think that's good enough for dataclasses.
Eric
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/BS2RRX62SHQDTM5O24WKAANPNHKXMG6F/
Code of Conduct: http://python.org/psf/codeofconduct/