py/objset: Simplify set and frozenset by separating their locals dicts.
A lot of set's methods (the mutable ones) are not allowed to operate on a frozenset, and giving frozenset a separate locals dict with only the methods that it supports allows to simplify the logic that verifies if args are a set or a frozenset. Even though the new frozenset locals dict is relatively large (88 bytes on 32-bit archs) there is a much bigger saving coming from the removal of a const string for an error message, along with the removal of some checks for set or frozenset type. Changes in code size due to this patch are (for ports that changed at all): unix x64: -56 unix nanbox: -304 stm32: -64 esp8266: -124 cc3200: -40 Apart from the reduced code, frozenset now has better tab-completion because it only lists the valid methods. And the error message for accessing an invalid method is now more detailed (it includes the method name that wasn't found).
Showing
Please register or sign in to comment