[pypy-dev] pip install rbtree fail in pypy env!
KaShining
mail2shine at qq.com
Sat Nov 2 10:44:59 CET 2013
I found bintrees-fastrbtree is the best choice:
(some test code:
def test_dict(tree, msg):
begin = time.time()
for i in range(100000):
k = random.randint(0, 10000000)
tree[k] = k
end = time.time()
print msg,end - begin
)
bintrees_rbtree under cpython 0.393133878708
bintrees_fast_rbtree under pypy 0.357424020767
------------------ Original ------------------
From: "Armin Rigo";<arigo at tunes.org>;
Date: Fri, Nov 1, 2013 05:06 PM
To: "KaShining"<mail2shine at qq.com>;
Cc: "Dan Stromberg"<drsalists at gmail.com>; "pypy-dev"<pypy-dev at python.org>;
Subject: Re: [pypy-dev] pip install rbtree fail in pypy env!
Hi KaShining,
Yes, the issue then is that pure Python equivalents are often slower
than their C version --- for example, this red_black_tree_mod file is
huge for the job (more than 1000 lines), written in a Java-ish style
with tons of small overridden methods, but full of properties,
recursive function invocations, and so on. Getting 10 times slower
than the C version is not good, but I guess that the C version was
more optimized. Often we can hope to get at most a few times slower.
PyPy is not faster at everything. Usually there is no way it can be
faster than a program that exercices only a CPython C extension
module. In some cases like this one, the solutions you have with PyPy
are all a lot slower --- both some pure Python version, and the cpyext
version. The pure Python version could be rewritten with
performance-on-PyPy in mind (just like the C version was written with
performance-on-CPython in mind).
Note that the point of red_black_tree_mod is very unclear to me. It
seems to replace plain dicts. Why can't you use plain dicts?
A bientôt,
Armin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20131102/260980b6/attachment.html>
More information about the pypy-dev
mailing list