What is the .pyc_dis file?

I have a folder with a .pyc_dis file from a module. What can i do with this? How to run it? What does this file consist of?

I could not find any information on a Google search.

Thank.

+3
source share
1 answer

this is probably the disassembled python bytecode obtained by decompyle . You can generate similar data as follows:

>>> 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)

Supplement file contents similar?

the bytecode disassembler is practically not useful, but can be used (and used by the disassembler decompiler) if you want to try to restore the python source code from the .pyc file.

UPDATE

eg. at startup

$ decompyle --showasm -o ./ app.pyc

app.pyc_dis, -, , :

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')
+4

Source: https://habr.com/ru/post/1759244/


All Articles