pypy

Making python quit program instantly when hitting ESC

大城市里の小女人 提交于 2019-12-18 09:55:06
问题 I'm making an algorithm that reads input from keyboard, stores it on a variable called message and then write this variable into a file. However, whenever the user is typing, if he hits the ESC key, I'd like the execution to stop without any errors. Let's say the code is: message = raw_input() What do I have to add? So if I'm in the middle of a sentence like: My name is th And I hit ESC, it stops? 回答1: There is no way to do this with normal input. raw_input reads a whole line at a time. In

Kivy, Eclipse and PyDev (also PyPy)

吃可爱长大的小学妹 提交于 2019-12-17 18:07:12
问题 According to this post: https://groups.google.com/forum/?fromgroups#!topic/kivy-users/n7c3thksnzg, it is possible to use Eclipse as an IDE for Kivy through PyDev. However, I didn't understand the instructions. Can anyone please elaborate on how to connect Kivy with Eclipse. Note: I'm on a Windows machine. Also, is it possible to use PyPy instead of the Python Interpreter? Thanks~! 回答1: Using Kivy with Pydev on Windows xp/7 Under Window/Preferences/PyDev/Interpreter-Python add a new

How to install lxml for PyPy?

a 夏天 提交于 2019-12-14 00:25:38
问题 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? 回答1: I used the following fork of lxml for

How to install pillow on pypy

久未见 提交于 2019-12-13 04:38:11
问题 How do I install pillow on Windows pypy with png support. I tried pypy -m pip install --use-wheel pillow This does not find a wheel file (for pypy), so it creates pillow, but does not include png support because it does not find zlib. I don't want to modify the setup.py, because I want to do this on multiple machines. 回答1: How about installing manually zlib.dll in system32? http://www.winimage.com/zLibDll/index.html 来源: https://stackoverflow.com/questions/20737151/how-to-install-pillow-on

Trying to solve of Project Euler #10, but code takes *a lot* of time to display output

不羁岁月 提交于 2019-12-13 04:32:25
问题 Project Euler Problem 10: The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17. Find the sum of all the primes below two million. I don't think there is any errors in my code. But it takes really a lot of time to give the answer. I've tried using PyPy because I've heard its faster than the CPython interpreter, but still no good. Here is the code: #Implementation of Sieve of Eratosthenes def prime_sieve(limit): primes = range(2, limit) for i in primes: for j in range(2, primes[-1]): try:

RPython ord() with non-ascii character

落花浮王杯 提交于 2019-12-13 04:16:05
问题 I'm making a virtual machine in RPython using PyPy. My problem is, that I am converting each character into the numerical representation. For example, converting the letter "a" provides this result, 97. And then I convert the 97 to hex, so I get: 0x61. So for example, I'm trying to convert the letter "á" into the hexadecimal representation which should be: 0xe1 but instead I get 0xc3 0xa1 Is there a specific encoding I need to use? Currently I'm using UTF-8. --UPDATE-- Where instr is "á" ,

Different sys.path between pypy and normal python

那年仲夏 提交于 2019-12-13 02:35:47
问题 I'm trying to use pypy compiler to run my python code but the sys.path for pypy is different from normal python compiler so when I tried to import default modules such as import pygame it fails in pypy, stating that the module is not found, while it works correctly with the normal python command. Any help is greatly appreciated. 回答1: I think you're expecting any module installed for CPython to work with PyPy out of the box. That's not the case. It's the same when you upgrade from CPython 2.6

Forcing modules to run in PyPy from a CPython script (run PyPy on part of the code)?

£可爱£侵袭症+ 提交于 2019-12-11 10:48:10
问题 Is there a way to import modules from a CPython script, but run them in PyPy? The problem is that I have a code that uses lots of SciPy (and NumPy), but there are parts of the code that could be optimized with PyPy. Here's a random example of what I would like to do: sub_run_in_pypy.py module: #assuming this can be optimized with PyPy def function_a(foo): return foo**2 main_run_in_cpython.py module: import scipy.stats as stats #assuming this exists: import import_function_for_pypy pypy

pypy: positional and named binds cannot be intermixed

谁都会走 提交于 2019-12-11 08:37:27
问题 I've successfully installed cx_Oracle on pypy using official patch. Now, everytime, django tries to execute any sql, I'm getting: MyTable.objects.using("ora").count() Traceback (most recent call last): File "<console>", line 1, in <module> File "/home/user/.virtualenvs/pypy_chembl_migration/site-packages/django/db/models/query.py", line 351, in count return self.query.get_count(using=self.db) File "/home/user/.virtualenvs/pypy_chembl_migration/site-packages/django/db/models/sql/query.py",

pip isn't working when importing something

随声附和 提交于 2019-12-11 07:39:38
问题 To install pymongo for pypy3 2.1 Beta 1, I installed pip using the following commands: wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py ./pypy ez_setup.py --user where pypy is the executable of pypy3 2.1 Beta 1. After that, pip and pip-3.2 will come to the current directory. But when running pip or pip-3.2, I get the error: Traceback (most recent call first): File "pip-3.2", line 5, in <module> from pkg_resources import load_entry_point zipimport.ZipImportError: pip==1.4.1