Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Python: compiled code sharing between several functions
# Compiled code sharing between
# several functions.
arr = []
for k in [1, 2, 3]:
arr.append(lambda: k)
print(arr[0].__code__ == arr[1].__code__) # True
print(arr[0].__code__.co_code) # bytecode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.