compiler-construction

Does strict typing increase Python program performance?

Does strict typing increase Python program performance? Question: Based on questions like this What makes C faster than Python? I’ve learned that dynamic/static typing isn’t the main reason that C is faster than Python. It appears to be largely because python programs are interpreted, and c programs are compiled. I’m wondering if strict typing would …

Total answers: 1

why python compiler doesn't ignore syntax errors after exit()?

why python compiler doesn't ignore syntax errors after exit()? Question: I have a question about the python compiler. I was running the below code but I got some errors that weren’t logical. if you run a python code and then add the exit() function to it, it would exit the program and the following codes …

Total answers: 1

How can i ignore comments in a string based on compiler design?

How can i ignore comments in a string based on compiler design? Question: I want to ignore every comment like { comments } and // comments. I have a pointer named peek that checks my string character by character. I know how to ignore newlines, tabs, and spaces but I don’t know how to ignore …

Total answers: 2

AoT Compiler for Python

AoT Compiler for Python Question: I want to get my Python script working on a bare metal device like microcontroller WITHOUT the need for an interpreter. I know there are already JIT compilers for Python like PyPy, and interpreters like CPython. However, existing interpreters I’ve seen (such as CPython) take up large memory (in MB …

Total answers: 3

Can we use C code in Python?

Can we use C code in Python? Question: I know that Python provides an API so you can call Python interpreter in C code, but what I want is the opposite. My program needs to use some C API, so the code must be written in C. But I also want to package the program …

Total answers: 2

It is more efficient to use if-return-return or if-else-return?

It is more efficient to use if-return-return or if-else-return? Question: Suppose I have an if statement with a return. From the efficiency perspective, should I use if(A > B): return A+1 return A-1 or if(A > B): return A+1 else: return A-1 Should I prefer one or another when using a compiled language (C) or …

Total answers: 9

How to install pywin32 module in windows 7

How to install pywin32 module in windows 7 Question: I am trying to install pywin32. I downloaded it from sourceforge.net. When I run setup.py install it shows “Unable to find vcvarsall.bat”. I Googled about it and found that I have to install MinGW and set path then run python setup.py build –compiler=mingw32 but it’s showing …

Total answers: 5

Can PyPy/RPython be used to produce a small standalone executable?

Can PyPy/RPython be used to produce a small standalone executable? Question: (Or, “Can PyPy/RPython be used to compile/translate Python to C/C++ without requiring the Python runtime?”) I have tried to comprehend PyPy with its RPython and its Python, its running and its compiling and its translating, and have somewhat failed. I have a hypothetical Python …

Total answers: 1

Python Compilation/Interpretation Process

Python Compilation/Interpretation Process Question: I’m trying to understand the python compiler/interpreter process more clearly. Unfortunately, I have not taken a class in interpreters nor have I read much about them. Basically, what I understand right now is that Python code from .py files is first compiled into python bytecode (which I assume are the .pyc …

Total answers: 2