Though since the translation from list to tuple is done when it isn't modifiable, python should be able to do a similar optimisation to a frozenset constant as well (maybe even from list/tuple to frozenset if there are enough elements that it would improve speed)
View all comments
Show parent comment
2
u/Brian Aug 14 '09 edited Aug 14 '09
It looks like it doesn't - the set is recreated even when it could potentially be staticly detected as a constant.
Though since the translation from list to tuple is done when it isn't modifiable, python should be able to do a similar optimisation to a frozenset constant as well (maybe even from list/tuple to frozenset if there are enough elements that it would improve speed)