bpo-38328: Speed up the creation time of constant set literals.#16878
bpo-38328: Speed up the creation time of constant set literals.#16878brandtbucher wants to merge 2 commits into
Conversation
|
@serhiy-storchaka, care to review (since you reviewed the other)? |
Sorry, something went wrong.
|
I think it should be implemented in AST, not in peephole. |
Sorry, something went wrong.
|
@methane I don’t think that there’s any precedent for adding nodes in the AST optimizer; just changing or removing existing ones. This change (and the other one for lists, which has already been approved by @serhiy-storchaka) would essentially require making a new constant, nesting that inside of a new star unpacking node, and nesting that inside of the final container literal node. The peephole optimizer already has the machinery for folding tuples, which can be trivially modified to work for lists and sets in this manner. Is there any reason you think it should be moved, other than the possibility of leaving unused constants in |
Sorry, something went wrong.
It may be done in the compiler instead of AST-optimizer. Even though some code are leaved in peephole, we had moved most optimizer to AST. Tuple folding is remaining in peephole only because some other AST nodes produce BUILD_TUPLE ops. |
Sorry, something went wrong.
|
Ah, I see. It looks like this can actually be done pretty easily in |
Sorry, something went wrong.
This is basically the same patch as #16498, except for sets. It's nearly identical, except that it adds a new argument to
fold_tuple_on_constantsto create afrozensetinstead.This one can probably be merged first, since the other PR is waiting for a list overallocation issue to be resolved.
https://bugs.python.org/issue38328