Skip to content

Instantly share code, notes, and snippets.

@DmitrySoshnikov
Created October 5, 2015 21:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DmitrySoshnikov/8dce08cf1790391570b5 to your computer and use it in GitHub Desktop.
Save DmitrySoshnikov/8dce08cf1790391570b5 to your computer and use it in GitHub Desktop.
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