Created
July 25, 2015 13:18
-
-
Save leeclemens/ea5d8bc737819bc9dd0e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import dis | |
class CSPROTO_CLASS(object): | |
EMPTY = b"" | |
CLOSE = b"<F2B_CLOSE_COMMAND>" | |
END = b"<F2B_END_COMMAND>" | |
CLOSE_END = CLOSE + END | |
class dotdict(dict): | |
def __getattr__(self, name): | |
return self[name] | |
CSPROTO_DOTDICT = dotdict({ | |
"EMPTY": b"", | |
"END": b"<F2B_END_COMMAND>", | |
"CLOSE": b"<F2B_CLOSE_COMMAND>" | |
}) | |
def getter_for_class(): | |
return CSPROTO_CLASS.CLOSE_END | |
def getter_for_dict(): | |
return CSPROTO_DOTDICT.CLOSE + CSPROTO_DOTDICT.END | |
dis.dis(getter_for_class) | |
print("-----------------------------") | |
dis.dis(getter_for_dict) | |
""" | |
24 0 LOAD_GLOBAL 0 (CSPROTO_CLASS) | |
3 LOAD_ATTR 1 (CLOSE_END) | |
6 RETURN_VALUE | |
----------------------------- | |
28 0 LOAD_GLOBAL 0 (CSPROTO_DOTDICT) | |
3 LOAD_ATTR 1 (CLOSE) | |
6 LOAD_GLOBAL 0 (CSPROTO_DOTDICT) | |
9 LOAD_ATTR 2 (END) | |
12 BINARY_ADD | |
13 RETURN_VALUE | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment