Why do C programs require decompilers, but python programs don't?

If I write a python script, anyone can just point the editor at it and read it. But for programming written in C, one would have to use decompilers and hexadecimal tables, etc. Why is this? I mean, I just can't open the Safari web browser and look at its code.

+3
source share
11 answers

Note. The author denies deep experience in this matter. Some statements may be incorrect.

Python is actually compiled into bytecode that is run by the python interpreter. Whenever you use the Python module, Python will generate a file .pycwith a name that matches the module. This is the equivalent of the file .ogenerated when compiling file C.

So, if you want to parse, the file .pycwill be next :)

The process Python executes when compiling a module is very similar to that of gccanother C compiler with the C source code. The main difference is that this happens transparently as part of the file execution. This is also optional: when you run a non-modular, that is, end-user script, Python will simply interpret the code, and not compile it in the first place.

, : " python , ?" , -: " C , ?"

C . , ( Linux) . , gentoo, - . , , - , .

. , Safari Mac Firefox Ubuntu Linux, , , (, x86_64) .

, , . , .

Python? -, Aaron , - Python. C . Python C.

, Python , C. , , - , , . : , Python , C-, Python - , C .

, py2exe, Python Windows, , Python. , , Python Windows, . linux, , OS/X, Python , . Linux -dandy , , Python, .

+13

Python - script, . C - , , , Python .

+10

. , , .

: Python - "" , , python ( python), . C ++ . , .

. Python -, "Just in Time", .

+5

: " python , ?"

, , - Python .

. , Unladen Swallow, Psyco, Shed Skin PyPy, , , .

  • Unladen Swallow - Python , LLVM . LLVM ( ) . Unladen Swallow LLVM , 1) - - 2009 , 2) : " Unladen Swallow 2009Q3".

  • Psyco Python, JIT, , ( ), , . , , , , .

  • Shed Skin Python-to-++ ++ , ++ () . 0.5 - .. , , . , , , -, .

  • PyPy - Python, Python. - , "", , , 4 , , , .

: , , , , , , . , .

+3

, python.

import dis

def foo():
    for i in range(100):
        print i

print dis.dis(foo)

( ) foo. , python. .pyc , script. , - python.

, python - , python. .

C , - , .

+2

, - Safari. , C , , "" .

, , , , Python. " URI", ", ".

, , , , , , , . , - , .

+2

C (), python . , python - , ( !). C .

+1
  • Python , , .. , .
  • C , . , . , .
0

Python , , ( , ). , , .

, , , (, , , ), C.

python "", C "", C- / .

python, . , .., . C-to-do, python .

0

C . C-, . Python- , bytecode (.pyc ).

, , , C , Python .

0

G-WAN ANSI C - , Python.

( G-WAN -) C, .

, G-WAN C , Python, PHP Java...

0

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


All Articles