pypy

Optimizing a reed-solomon encoder (polynomial division)

吃可爱长大的小学妹 提交于 2019-12-04 15:42:11
问题 I am trying to optimize a Reed-Solomon encoder, which is in fact simply a polynomial division operation over Galois Fields 2^8 (which simply means that values wrap-around over 255). The code is in fact very very similar to what can be found here for Go: http://research.swtch.com/field The algorithm for polynomial division used here is a synthetic division (also called Horner's method). I tried everything: numpy, pypy, cython. The best performance I get is by using pypy with this simple nested

How to install lxml for PyPy?

亡梦爱人 提交于 2019-12-04 13:51:00
I've created a virtualenv for PyPy with: virtualenv test -p `which pypy` source test/bin/activate I installed the following dependencies: sudo apt-get install python-dev libxml2 libxml2-dev libxslt-dev And then I run: pip install --upgrade pypy As a result I get a lot of errors looking like this: src/lxml/lxml.etree.c:234038:22: error: `PyThreadState` {aka struct _ts}` has no member named `use_tracing` How do I properly install lxml for PyPy 2.6.0? I used the following fork of lxml for PyPy instead: https://github.com/aglyzov/lxml/tree/cffi It can be installed with: pip install -e git+git:/

PyPy file append mode

别来无恙 提交于 2019-12-04 11:52:02
问题 I have code like this: f1 = open('file1', 'a') f2 = open('file1', 'a') f1.write('Test line 1\n') f2.write('Test line 2\n') f1.write('Test line 3\n') f2.write('Test line 4\n') When this code is run with standard Python 2.7 interpreter, the file contains four lines as expected. However, when I run this code under PyPy, the file contains only two lines. Could someone explain the differences between Python and PyPy in working with files in append mode? UPDATED : The problem doesn't exist in the

How to use PIL with PyPy?

泄露秘密 提交于 2019-12-04 11:20:45
问题 I searched a little bit but I couldn't find a tuto to use PIL with PyPy. According to PyPy's blog, PIL is supported. I installed PIL with pip in my PYTHONPATH. After the download, pip make 2 .pyd files: _imaging.pyd and _imagingmath.pyd. After the install, I copied %PYTHONPATH%/lib/site-packages/PIL to my PyPy site-packages directory. When I run my script (which uses PIL), it says it can't import the _imaging C module. How should I do it ? edit: I run this on Windows 7 x64 (python 2.7.1

python json高性能处理

血红的双手。 提交于 2019-12-04 10:35:21
网上一圈发现,python2里ujson评价最高,而python3里orjson评价不错 选了一个稍微有点尺寸的 json数据做了下试验 root@ubuntu:/home/yey/perftest# python jsonbench.py json.loads 51582/sec ujson.loads 202109/sec json.dumps 97214/sec ujson.dumps 187700/sec ujson的loads是json的4倍, ujson的dumps是json的2倍,似乎是不错。 并且从网上的评价来看,ujson似乎是python2下的最佳选择了。 在我的场景中,我需要高性能的处理,为此我引入了pypy, 看上面的结果,我想当然的使用了pypy + ujson的组合,结果却不理想,研究发现一个惊人反转:pypy+ujson < python+json < python+ujson < pypy+json root@ubuntu:/home/yey/perftest# pypy/bin/pypy jsonbench.py json.loads 403308/sec ujson.loads 42868/sec json.dumps 210220/sec ujson.dumps 20783/sec 结论,如果只需要loads, 那么最快的是pypy+json

Is it possible to run a pypy kernel in the Jupyter notebook?

被刻印的时光 ゝ 提交于 2019-12-04 10:13:58
问题 I have always wondered if it were possible to run PyPy in the Jupyter notebook. I recently tried installing PyPy on my local machine, and it ran really well - 100X speedup in an agent-based simulation written in pure Python. However, I miss the interactivity in the Jupyter notebook. Is it possible to make the IPython kernel use PyPy rather than CPython? 回答1: You can install Jupyter with pypy: pypy-pip install jupyter The are problems on Mac OS X. If the install fails complaining a about

Can I embed CPython inside PyPy?

南笙酒味 提交于 2019-12-04 09:21:36
I'd like to write a performance-sensitive application in Python, so executing it under PyPy is a natural choice. However, a significant portion of my code depends on numpy, scipy, and scikit-learn. Would it be possible to embed a CPython instance within a running PyPy program in order to call array-oriented code? If not, what's the easiest way to make PyPy and CPython talk to each other? No, you can't embed CPython inside PyPy AFAIK. You can, however, use distributed/parallel execution systems to make PyPy talk to CPython. Both execnet and Pyro mention this precise PyPy <-> CPython use case.

Disabling std. and file I/O in Python sandbox implementation

自古美人都是妖i 提交于 2019-12-04 07:29:27
I'm trying to set up a Python sandbox and want to forbid access to standard and file I/O. I am running the sandbox inside of a running Python server. I've already looked at modules like RestrictedPython and PyPy ; however, I want to be able to compile the sandbox code inside of my running Python server, not through an external process. Are there any alternative ways to prevent access to commands like print , raw_input , or open ? Could the aforementioned modules be used in a way where sandbox code is compiled in a running Python program? At worst, how would you prevent access to raw_input ?

Why wasn't PyPy included in standard Python?

百般思念 提交于 2019-12-04 07:23:24
问题 I was looking at PyPy and I was just wondering why it hasn't been adopted into the mainline Python distributions. Wouldn't things like JIT compilation and lower memory footprint greatly improve the speeds of all Python code? In short, what are the main drawbacks of PyPy that cause it to remain a separate project? 回答1: PyPy is not a fork of CPython, so it could never be merged directly into CPython. Theoretically the Python community could universally adopt PyPy, PyPy could be made the

Using the socket module in sandboxed Pypy

南楼画角 提交于 2019-12-04 06:40:30
I'm attempting to allow a subprocess sandboxed with Pypy to communicate, using a limited protocol, with the parent process. After reviewing the source code of the pypy/pypy/translator/sandbox/sandlib.py included with Pypy, it appears that there is a VirtualizedSocketProc that allows os.open calls to open sockets. I've changed some functionality of the code (for example, allowing TCP connections on limited ports), but very little has been changed. However, I'm unable to actually import Pypy's socket module because it requires a non-existent _socket module, which seems to be located in the