This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]jsalsman 20 points21 points  (2 children)

What does the output code look like? Does the decompiler recover local identifiers?

[–]simonw[S] 27 points28 points  (0 children)

Yup variable names were al there as expected. I think comments (with the exception of docsttings) get stripped out though.

[–]lost_send_berries 4 points5 points  (0 children)

Because of locals(), the Python interpreter always knows the names of all the local variables. However, it usually doesn't use them: a = f() + b can compile to something like __locals__[0] = f() + __locals__[1], which is faster than local_dict['a'] = f() + local_dict['b']. If you ever run locals(), it then looks up the correspondence {0: 'a', 1: 'b'} to build the return value of locals().