cfbolz changed the topic of #pypy to: PyPy, the flexible snake (IRC logs: https://botbot.me/freenode/pypy/ ) | use cffi for calling C | the secret reason for us trying to get PyPy users: to test the JIT well enough that we're somewhat confident about it
<kenaan>
wlav cppyy-packaging d72f3ca3c3fd /: merge default into branch
hotpot34 has quit [Read error: Connection reset by peer]
<arigato>
tsutsumi: if the program is mostly Python code calling C functions from zmq, compiled used the C extension compatibility layer cpyext, then it is expected to be a bit slower than CPython
<arigato>
particularly if you do many, many such calls
<tsutsumi>
arigato: got it. so I guess optimizing often-executed areas using c extensions as with CPython isn't a good option with pypy?
<tsutsumi>
I guess I head an idea in my head where we can achieve some pretty big performance boosts using pypy + cython / c extensions combined, but one or the other is probably what it comes down to?
<arigato>
it all depends on how often execution crosses the barrier
<arigato>
if it's rare, then it's going to be a net speed-up
<arigato>
the extreme example would be to define a Vector3 class in C, and use that all the time for computations done in Python
<arigato>
you'd get two crosses of the barrier for each operation
<arigato>
whereas just writing the Vector3 class in Python, PyPy would inline its operations completely and the net result would be fast (relatively, much much much faster)
<arigato>
so no, the good approach if you start with PyPy is to write everything in Python, and then profile to know if it makes any sense to rewrite some well-separated parts in Cython
<arigato>
(to call external C libraries, use cffi, not cython)
<tsutsumi>
right. but better than cython would be writing the python code in a way where pypy's JIT could compile it down to native functions, correct?
<arigato>
that's automatic
<tsutsumi>
hmm.. is there ever a situation where using Cython or cpyext is a good choice for pypy, aside from compatibility with existing packages using c extensions?
<arigato>
it's unclear, but I can think about some cases where the Cython or cpyext version contains medium- or long-running algorithms that are written or compiled to C code, without using the slower "PyObject *"
<arigato>
i.e. if you could, in theory, take the Cython or cpyext project and extract some general-purpose cpu-heavy C library out of it
<tsutsumi>
ah right, yeah. If there's some really extensive operations that need to be performed, and the number of times one has to cross the barrier is low
<arigato>
yes
<arigato>
in cases where you really need C code but need to cross the barrier often, then the way to go is using CFFI to directly call a C library
<tsutsumi>
Ah ok, so CFFI is a more performant option than the cpython extension way
<tsutsumi>
that sounds like a good route. Looking at pyzmq, it looks like there is a CFFI backend, but it's only available for newer versions of zeromq