Compiled bytecode
Rocco Moretti
roccomoretti at hotpop.com
Thu Dec 30 16:07:21 EST 2004
Peter Hansen wrote:
> The main script is generally not compiled, but all imported
> scripts are generally compiled automatically, the first time
> they are imported, and never again unless the source changes.
Someone please correct me if I'm wrong, but I'm under the impression
that the main script *is* compiled, but the byte-code compiled file is
kept in memory, and not written to disk.
That's what makes this work:
------ file1.py -----
import dis
def f():
a = 1
print a
dis.dis(f)
---------------------
> python file1.py
4 0 LOAD_CONST 1 (1)
3 STORE_FAST 0 (a)
5 6 LOAD_FAST 0 (a)
9 PRINT_ITEM
10 PRINT_NEWLINE
11 LOAD_CONST 0 (None)
14 RETURN_VALUE
>
----------------------
More information about the Python-list
mailing list