I want to know how to run pypy or cyton on the window.

Asked 2 years ago, Updated 2 years ago, 54 views

I installed an anaconda 3 (python 3.6) version in a Windows environment and am working on it.

The Python language itself is simple, so it is not difficult to write the source itself, but I felt that if the source was slightly longer, it would be slower than Excel.

I looked up Python to improve its speed and found that there were ways like cython and pypy.

I'd like to know how to use the utility?

http://pypy.org/download.html#default-with-a-jit-compiler

The above address is a site where you can receive a pypy that is faster than Cython.

However, the binary for Python 3.6 Windows has not been created yet, so we are installing a virtual machine (VM Virtual Box) and installing Ubuntu.

Most Python libraries or sources have to be installed in Ubuntu.

I also wonder if the installation through Ubuntu in the virtual machine that we are doing now is also applied in Windows.

To summarize the question, we are looking for ways to improve Python's slow speed.

I'd like to know the answer to the method and the method of the answer. Please give me some advice.

pypy cython ubuntu

2022-09-22 10:34

2 Answers

Pypy has a built-in jit compiler that is compiled into binary code and executes the result. This means that it executes binary code, so of course it performs well.

Cython is the c code translator, and the result of transpiled to cython is the c code. The c code created in that way is for the c expansion module, so generate a pyd through the c compiler and use it in Python. Of course, it is a c code, so it has good performance.

The advantage of pypy is that it is compatible with python, so you can use the python code as it is.

Cython has the advantage of being able to use the existing c code as it is, and the advantage of being able to write the c extension module in Python format.

Pypy is easy if you have to improve the performance easily, but there is a limit to optimization.

On the other hand, cython has to use the c compiler, so the running curve is quite good, but you can use the c code as it is, so you can maximize optimization can be maximized.


2022-09-22 10:34

%load_ext Cython

%%cython
from libc.math cimport sin, round, M_PI
def fsin(degree):
    cdef double r = round(sin(M_PI * degree / 180) * 10000) / 10000
    return r

fsin(45)
Out[3]: 0.7071

fsin(30)
Out[4]: 0.5

fsin(90)
Out[5]: 1.0

Environment: windows 7 (x64), visual studio 2015 community

You can compile comfortably using a function called cython magic in the jupyter (ipython) as shown above.


2022-09-22 10:34

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.