New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimize the empty set "literal" #77381
Comments
The following PR optimizes bytecode for the empty set "literal": {*()}. Currently it is compiled to
It will optimized to
$ ./python -m perf timeit --duplicate 1000 '{*()}' Unpatched: Mean +- std dev: 68.6 ns +- 1.1 ns |
Does anyone seriously write "{*()}" instead of "set()"? |
Don't know. :-) Consider this as a 1st April egg. |
It doesn't seem to be laughing to me. |
I may have immediately latched onto this, dubbing it the "one-eyed monkey operator", the moment the generalized unpacking released. I always hated the lack of an empty set literal, and enjoyed having this exist just to fill that asymmetry with the other built-in collection types (that said, I never use it in production code, nor teach it in classes I run). |
Closed due to the lack of practical applications. Can be reopened if this idiom become popular. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: