Issue33200
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2018-04-01 10:29 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 6330 | closed | serhiy.storchaka, 2018-04-01 10:35 | |
| Messages (6) | |||
|---|---|---|---|
| msg314769 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2018-04-01 10:29 | |
The following PR optimizes bytecode for the empty set "literal": {*()}.
Currently it is compiled to
LOAD_CONST 0 (())
BUILD_SET_UNPACK 1
It will optimized to
BUILD_SET 0
$ ./python -m perf timeit --duplicate 1000 '{*()}'
Unpatched: Mean +- std dev: 68.6 ns +- 1.1 ns
Patched: Mean +- std dev: 31.8 ns +- 2.8 ns
|
|||
| msg314771 - (view) | Author: Mark Dickinson (mark.dickinson) * ![]() |
Date: 2018-04-01 11:35 | |
Does anyone seriously write "{*()}" instead of "set()"?
|
|||
| msg314772 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2018-04-01 11:56 | |
Don't know. :-) Consider this as a 1st April egg. |
|||
| msg314790 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2018-04-01 23:32 | |
> Does anyone seriously write "{*()}" instead of "set()"?
It doesn't seem to be laughing to me.
|
|||
| msg314849 - (view) | Author: Josh Rosenberg (josh.r) * ![]() |
Date: 2018-04-03 02:15 | |
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). |
|||
| msg315138 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * ![]() |
Date: 2018-04-09 16:35 | |
Closed due to the lack of practical applications. Can be reopened if this idiom become popular. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:58:59 | admin | set | github: 77381 |
| 2018-04-09 16:35:29 | serhiy.storchaka | set | status: open -> closed resolution: rejected messages: + msg315138 stage: patch review -> resolved |
| 2018-04-03 02:15:45 | josh.r | set | nosy:
+ josh.r messages: + msg314849 |
| 2018-04-01 23:32:45 | pitrou | set | nosy:
+ pitrou messages: + msg314790 |
| 2018-04-01 11:56:26 | serhiy.storchaka | set | messages: + msg314772 |
| 2018-04-01 11:35:45 | mark.dickinson | set | nosy:
+ mark.dickinson messages: + msg314771 |
| 2018-04-01 10:35:12 | serhiy.storchaka | set | keywords:
+ patch stage: patch review pull_requests: + pull_request6043 |
| 2018-04-01 10:29:26 | serhiy.storchaka | create | |

