Open
Description
Some set constants can be replaced by frozensets, e.g. in cases like x in {1,2,3}
. This would allow them to become global constants, created once at module init time. There is already a framework for merging tuple and string constants, see TupleNode
. The ConstantFolding
transformation could detect these cases and set a flag attribute on the SetNode
instances that would trigger constant frozenset behaviour.
Other potential candidates:
>>> frozenset((1,2,3)) | {2,3,4} # imagine one side being non-constant
frozenset([1, 2, 3, 4])
>>> {3,4,5} | frozenset((1,2,3))
set([1, 2, 3, 4, 5])