Questions tagged [pyc]

Python source code is automatically compiled into Python byte code by the CPython interpreter. Compiled code is usually stored in .pyc files, and is regenerated when the source is updated, or when otherwise necessary.

195 questions
15
votes
3 answers

Given a python .pyc file, is there a tool that let me view the bytecode?

A Python module is automatically compiled into a .pyc file by CPython interpreter. The .pyc file, which contains the bytecode, is in binary format (marshaled code?). Is there a GUI (or command line) tool that let me view the bytecode?
dividebyzero
  • 1,243
  • 2
  • 9
  • 17
12
votes
1 answer

How to run python production on customer environment

I have some python application that should run on customer site. I compile my py files to pyc (python byte code). What is the standard way to run the app on the customer environment? The options I see are: As part of my installer, install some…
Mugen
  • 8,301
  • 10
  • 62
  • 140
12
votes
1 answer

How can I understand a .pyc file content

I have a .pyc file. I need to understand the content of that file to know how the disassembler works of python, i.e. how can I generate a output like dis.dis(function) from .pyc file content. for e.g. >>> def sqr(x): ... return x*x ... >>>…
Niya Simon C
  • 279
  • 2
  • 4
  • 10
10
votes
1 answer

Should __pycache__ folders be included in production containers?

I am wondering if keeping __pycache__ folders and .pyc files in built containers is good or bad practice. On one side you want to minimize the size of the containers but on the other side you do not want to slowdown the container executions…
sorin
  • 161,544
  • 178
  • 535
  • 806
10
votes
2 answers

How to make a .pyc file from Python script

I know that when Python script is imported in other python script, then a .pyc script is created. Is there any other way to create .pyc file by using linux bash terminal?
MikhilMC
  • 949
  • 3
  • 8
  • 14
9
votes
1 answer

Cannot see pyc files in PyCharm

I am using PyCharm for a project and I need to access pyc files. Unfortunately, IDE seems not to show *.pyc files nor __pycache__, even in searches with double Shift+Shift. I cannot find settings or documentation about it. Do you have any idea on…
Lore
  • 1,286
  • 1
  • 22
  • 57
9
votes
1 answer

Byte code of a compiled script differs based on how it was compiled

Earlier in the day, I was experimenting heavily with docstrings and the dis module, and came across something I can't seem to find the answer for. First, I create a file test.py with the following content: def foo(): pass Just this, and…
cs95
  • 379,657
  • 97
  • 704
  • 746
9
votes
1 answer

Python bytecode and .pyc file format specification

I'm looking for pyc file format specification. I found this link that provides bytecode instructions without the opcodes but I need a lot more detailed file that includes the file structure of the .pyc. Can anyone provide me a link to it?
Kikapi
  • 369
  • 1
  • 2
  • 11
9
votes
4 answers

How to avoid creation of .pyc files on OS X 10.8 with Python 2.7?

It seems that on OS X 10.8 (with Python 2.7) the .pyc files are created even if you setup the environment variable PYTHONDONTWRITEBYTECODE=1 How can I prevent this from happening, or how can I convince Python not to create this files in the same…
sorin
  • 161,544
  • 178
  • 535
  • 806
9
votes
1 answer

Python 2 and 3, are the bytecode (pyo & pyc) backward compatible?

Python 2 and 3, are the bytecode (pyo & pyc) backward compatible? can i execute python 2 pyo & pyc file with python 3?
coffeeground
  • 139
  • 8
8
votes
5 answers

is there any kind of performance gain while using .pyc files in python?

We can write a piece of python code and put it in already compiled ".pyc" file and use it. I am wondering that is there any kind of gain in terms of performance or it is just a kind of modular way of grouping the code. Thanks a lot
Shan
  • 18,563
  • 39
  • 97
  • 132
8
votes
3 answers

importing a module in Idle shell

I'm trying to learn python and I'm having trouble importing a module. I have a .pyc file that I'm trying to import into idle shell called dfa.pyc I have the file in a folder called xyz. I navigate to this folder using: …
android_student
  • 1,246
  • 1
  • 13
  • 32
8
votes
1 answer

How to run a Django project with .pyc files without using source codes?

I have a django project and i want to create the .pyc files and remove the source code. My project folder name is mysite and I ran the command python -m compileall mysite. The .pyc files are created. After that i tried to run my project with python…
Aslı Kök
  • 616
  • 8
  • 19
8
votes
4 answers

Stop Python from generating pyc files in shebang

Is there a way to stop python from creating .pyc files, already in the shebang (or magic number if you will) of the Python script? Not working: #!/usr/bin/env python -B
Prof. Falken
  • 24,226
  • 19
  • 100
  • 173
7
votes
2 answers

How can I decompile .pyc files from Python 3.10?

I did try uncompyle6, decompyl3, and others, but none of them worked with 3.10. Is it even possible to do this right now?
Rana
  • 81
  • 1
  • 1
  • 3
1
2
3
12 13