I have a folder that has a .pyc_dis file from a module. What can I do with it? How do I run it? What does this file even come from?
I couldn't find any information with a G开发者_运维技巧oogle search.
Thanks.
it's probably a disassembled python bytecode obtained by decompyle. you can generate similar data like this:
>>> import code, dis
>>> c = code.compile_command('x = []; x.append("foo")')
>>> dis.disassemble(c)
1 0 BUILD_LIST 0
3 STORE_NAME 0 (x)
6 LOAD_NAME 0 (x)
9 LOAD_ATTR 1 (append)
12 LOAD_CONST 0 ('foo')
15 CALL_FUNCTION 1
18 PRINT_EXPR
19 LOAD_CONST 1 (None)
dos the file content look similar?
the bytecode disassembly is not practically useful, but can be used (and is used by decompyle disassembler) if one wants to try to reconstruct the python source code from .pyc file.
UPDATE
e.g. when you run
$ decompyle --showasm -o ./ app.pyc
the app.pyc_dis
file containing the bytecode analysis is generated in the current directory, and in my simple example its content is:
0 BUILD_LIST_0 ''
3 STORE_NAME 'x'
6 LOAD_NAME 'x'
9 LOAD_ATTR 'append'
12 LOAD_CONST 'foo'
15 CALL_FUNCTION_1 ''
18 POP_TOP ''
19 LOAD_CONST ''
22 RETURN_VALUE ''
x = []
x.append('foo')
精彩评论