Disassemble Python - Under the hood
Ever thought about what python does under the hood? With the standard library module dis, you can do that easily.
Python: 3.0    Anurag Rana    06 Jul 2021   0
Login to upvote
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
import dis 
def test(number): 
    return (str(number)+str(number)) 
dis.dis(test) 

''' 
Result: 
  8           0 LOAD_GLOBAL              0 (str) 
              3 LOAD_FAST                0 (number) 
              6 CALL_FUNCTION            1 (1 positional, 0 keyword pair) 
              9 LOAD_GLOBAL              0 (str) 
             12 LOAD_FAST                0 (number) 
             15 CALL_FUNCTION            1 (1 positional, 0 keyword pair) 
             18 BINARY_ADD 
             19 RETURN_VALUE 
#can we speed it up? 
'''
Copy | Download as: .py file   PNG
Share on: FB   Twitter   LinkedIn   WA
©2021 - code108labs   Contributors   Hosted on DigitalOcean   Partner website: pythoncircle.com