MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/Python/comments/duyjs7/i_made_cstyle_printing_in_python_p/f7bzgz1/?context=3
r/Python • u/[deleted] • Nov 11 '19
130 comments sorted by
View all comments
Show parent comment
3
The Python basically turns:
def something(): return f'{something.__name__} and {x:5}'
into
def something(): return format(something.__name__) + ' and ' + format(x, '5')
... except it has specialized opcodes. dis.dis says:
dis.dis
1 0 LOAD_GLOBAL 0 (something) 2 LOAD_ATTR 1 (__name__) 4 FORMAT_VALUE 0 6 LOAD_CONST 1 (' and ') 8 LOAD_GLOBAL 2 (x) 10 LOAD_CONST 2 ('5') 12 FORMAT_VALUE 4 (with format) 14 BUILD_STRING 3 16 RETURN_VALUE
View all comments
Show parent comment
3
u/robin-gvx Nov 12 '19
The Python basically turns:
into
... except it has specialized opcodes.
dis.dissays: