Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Maciej Fijalkowski
On Tue, Feb 14, 2012 at 8:13 PM, Stefan Behnel wrote: > Maciej Fijalkowski, 14.02.2012 19:00: >> On Tue, Feb 14, 2012 at 7:56 PM, Stefan Behnel wrote: >>> Amaury Forgeot d'Arc, 14.02.2012 18:45: 2012/2/14 Stefan Behnel > if PyPy can't come up with a fast way to > interface with C code

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Stefan Behnel
Stefan Behnel, 14.02.2012 19:13: > Simple questions: > > Is rffi usable in this context or is it not? Does it require RPython code > to be generated or does it also work with Python code? How do callbacks > work in rffi? Does rffi provide access to PyPy objects? And how so? > > I don't know all t

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread mark florisson
On 14 February 2012 18:10, Antonio Cuni wrote: > On 02/14/2012 06:56 PM, Stefan Behnel wrote: >> >> Ok, then I take it that this would be the preferred Python+FFI approach >> for >> interfacing, right? ctypes is out of the loop? > > > note that there are at least two different levels to interface

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Stefan Behnel
Maciej Fijalkowski, 14.02.2012 19:00: > On Tue, Feb 14, 2012 at 7:56 PM, Stefan Behnel wrote: >> Amaury Forgeot d'Arc, 14.02.2012 18:45: >>> 2012/2/14 Stefan Behnel if PyPy can't come up with a fast way to interface with C code, it's bound to die. >>> >>> But it certainly can! For example

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Antonio Cuni
On 02/14/2012 06:56 PM, Stefan Behnel wrote: Ok, then I take it that this would be the preferred Python+FFI approach for interfacing, right? ctypes is out of the loop? note that there are at least two different levels to interface with C code. The first is using rffi, which lets you to call C

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread mark florisson
On 14 February 2012 18:00, Maciej Fijalkowski wrote: > On Tue, Feb 14, 2012 at 7:56 PM, Stefan Behnel wrote: >> Amaury Forgeot d'Arc, 14.02.2012 18:45: >>> 2012/2/14 Stefan Behnel if PyPy can't come up with a fast way to interface with C code, it's bound to die. >>> >>> But it certainly

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Maciej Fijalkowski
On Tue, Feb 14, 2012 at 7:56 PM, Stefan Behnel wrote: > Amaury Forgeot d'Arc, 14.02.2012 18:45: >> 2012/2/14 Stefan Behnel >>> if PyPy can't come up with a fast way to >>> interface with C code, it's bound to die. >> >> But it certainly can! For example PyPy implements the _ssl and pyexpat >> modu

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Stefan Behnel
Amaury Forgeot d'Arc, 14.02.2012 18:45: > 2012/2/14 Stefan Behnel >> if PyPy can't come up with a fast way to >> interface with C code, it's bound to die. > > But it certainly can! For example PyPy implements the _ssl and pyexpat > modules, > which are interfaces to the openssl and expat libraries

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Armin Rigo
Hi Stefan, On Tue, Feb 14, 2012 at 18:24, Stefan Behnel wrote: > My personal take on this is: if PyPy can't come up with a fast way to > interface with C code, it's bound to die. (...) I think you are seeing the world through the pin's hole of what would be needed for Cython's C files to compile

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Amaury Forgeot d'Arc
2012/2/14 Stefan Behnel > if PyPy can't come up with a fast way to > interface with C code, it's bound to die. > But it certainly can! For example PyPy implements the _ssl and pyexpat modules, which are interfaces to the openssl and expat libraries. And it does that by generating C code that cal

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Maciej Fijalkowski
On Tue, Feb 14, 2012 at 7:24 PM, Stefan Behnel wrote: > Armin Rigo, 14.02.2012 16:12: >> On Tue, Feb 14, 2012 at 14:12, Stefan Behnel wrote: >>> Hmm, if that is so, how would you ever want to make PyPy bidirectionally >>> interface with anything at all? How does ctypes even work in PyPy? >> >> I b

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Romain Guillebert
Hi everyone Having work on the Python backend for Cython I can give you what I think are the main hassles. First, ctypes semantics don't match Cython semantics (which is way closer, in a good way, to C) Second, if you work with the AST, you should reimplement stuff that don't change between Cyth

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Stefan Behnel
Armin Rigo, 14.02.2012 16:12: > On Tue, Feb 14, 2012 at 14:12, Stefan Behnel wrote: >> Hmm, if that is so, how would you ever want to make PyPy bidirectionally >> interface with anything at all? How does ctypes even work in PyPy? > > I believe you are not understanding my point. Obviously ctypes

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Martijn Faassen
Hey, On Tue, Feb 14, 2012 at 4:28 PM, mark florisson wrote: [snip] >> There is no way to map that to Python unless you use something like >> ctypes (but ctypes is not considered to be right for this purpose). > > Why is ctypes not right? Cython could actually generate a C function > with a known

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Armin Rigo
Hi Mark, On Tue, Feb 14, 2012 at 16:22, mark florisson wrote: > (...) Going the python + ctypes way through to the end, > and supporting all the features, will be a lot of work. (...) I think that your points are valid and need to be carefully considered. I was taking a bit of an extreme opposi

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread wlavrijsen
Hi, On Tue, 14 Feb 2012, mark florisson wrote: 1) C++ support (http://docs.cython.org/src/userguide/wrapping_CPlusPlus.html) [.. snip ..] Under this model I think the first three points are particularly though. Could RPython in any way alleviate the countless problems with this approach (

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread mark florisson
On 14 February 2012 15:25, Martijn Faassen wrote: > On Tue, Feb 14, 2012 at 4:19 PM, Armin Rigo wrote: >> Hi Martijn, >> >> On Tue, Feb 14, 2012 at 14:47, Martijn Faassen >> wrote: >>> But Cython-based code does talk to C APIs, so there is a problem. >>> Python code in PyPy needs to be able to

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread mark florisson
On 14 February 2012 15:12, Armin Rigo wrote: > Hi Stefan, > > On Tue, Feb 14, 2012 at 14:12, Stefan Behnel wrote: >> Hmm, if that is so, how would you ever want to make PyPy bidirectionally >> interface with anything at all? How does ctypes even work in PyPy? > > I believe you are not understandi

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Martijn Faassen
On Tue, Feb 14, 2012 at 4:19 PM, Armin Rigo wrote: > Hi Martijn, > > On Tue, Feb 14, 2012 at 14:47, Martijn Faassen wrote: >> But Cython-based code does talk to C APIs, so there is a problem. >> Python code in PyPy needs to be able to interface with C APIs first in >> order to generate the right

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread mark florisson
On 14 February 2012 13:21, Maciej Fijalkowski wrote: > On Tue, Feb 14, 2012 at 3:12 PM, Stefan Behnel wrote: >> Armin Rigo, 14.02.2012 13:13: >>> the main problem is that the RPython-to-C translation that we >>> do is not just a one-format traduction.  We need to tweak the >>> intermediate code i

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Armin Rigo
Hi Martijn, On Tue, Feb 14, 2012 at 14:47, Martijn Faassen wrote: > But Cython-based code does talk to C APIs, so there is a problem. > Python code in PyPy needs to be able to interface with C APIs first in > order to generate the right stuff from Cython. That's not necessarily hard. I believe

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Armin Rigo
Hi Stefan, On Tue, Feb 14, 2012 at 14:12, Stefan Behnel wrote: > Hmm, if that is so, how would you ever want to make PyPy bidirectionally > interface with anything at all? How does ctypes even work in PyPy? I believe you are not understanding my point. Obviously ctypes works in PyPy, and not, I

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Armin Rigo
Hi Antonio, On Tue, Feb 14, 2012 at 13:23, Antonio Cuni wrote: > this approach would work for all C extensions then, not just Cython's one, > right? No. Or maybe yes, but with much more work. I'm suggesting to take specifically the Cython-produced C files, with all macros redefined to strange

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Martijn Faassen
Hi there, So if I understand the direction of this discussion correctly, it is suggested that to interface PyPy with Cython in a non-hackish way the best strategy might be to modify Cython to generate Python code. This way, there's no need to expose all sorts of PyPy internals on a C API level, an

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Antonio Cuni
On 02/14/2012 02:21 PM, Maciej Fijalkowski wrote: I think CPython C API is a serious part of it's success because it's "good enough for a lot of cases" not because it's necessary for it's success. In my opinion a decent FFI (not ctypes, I mean a decent one) and better performance would eliminate

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Maciej Fijalkowski
On Tue, Feb 14, 2012 at 3:12 PM, Stefan Behnel wrote: > Armin Rigo, 14.02.2012 13:13: >> the main problem is that the RPython-to-C translation that we >> do is not just a one-format traduction.  We need to tweak the >> intermediate code in various ways depending on various settings.  The >> way it

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Stefan Behnel
Armin Rigo, 14.02.2012 13:13: > the main problem is that the RPython-to-C translation that we > do is not just a one-format traduction. We need to tweak the > intermediate code in various ways depending on various settings. The > way it is tweaked really depends on these settings in a way that >

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Stefan Behnel
Armin Rigo, 14.02.2012 13:18: > On Tue, Feb 14, 2012 at 13:13, Armin Rigo wrote: >> For this reason, I remain convinced that the best approach for Cython >> on PyPy is instead to have Cython generate pure Python code that would >> use some API in the form of a built-in Python module. > > For what

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Amaury Forgeot d'Arc
2012/2/14 Armin Rigo > As a rather extreme solution: I wonder how useful it would be to use > gcc to cross-compile the C intermediate sources to MIPS assembler, and > write a MIPS interpreter in RPython... (MIPS because it's apparently > a very simple instruction set) > Are you suggesting somet

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Antonio Cuni
On 02/14/2012 01:18 PM, Armin Rigo wrote: As a rather extreme solution: I wonder how useful it would be to use gcc to cross-compile the C intermediate sources to MIPS assembler, and write a MIPS interpreter in RPython... (MIPS because it's apparently a very simple instruction set) this approac

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Armin Rigo
Re-Hi, On Tue, Feb 14, 2012 at 13:13, Armin Rigo wrote: > For this reason, I remain convinced that the best approach for Cython > on PyPy is instead to have Cython generate pure Python code that would > use some API in the form of a built-in Python module. For what it's worth, it would work if t

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Armin Rigo
Hi Fijal, On Tue, Feb 14, 2012 at 10:50, Maciej Fijalkowski wrote: > The thing is noone seriously works on the cython's pypy backend, so > the dirty hacks seem like a very good solution short-to-mid term. Someone feel free to try them out. However I'm generally negative about the outcome and it

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Maciej Fijalkowski
On Tue, Feb 14, 2012 at 11:48 AM, Antonio Cuni wrote: > On 02/14/2012 10:41 AM, Amaury Forgeot d'Arc wrote: >> >> >>    Seriously - we control the code on both sides. I think the >> possibilities >>    are endless. >> >> >> Why only think in terms of C code then? The best API pypy offers so far >>

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Antonio Cuni
On 02/14/2012 10:41 AM, Amaury Forgeot d'Arc wrote: Seriously - we control the code on both sides. I think the possibilities are endless. Why only think in terms of C code then? The best API pypy offers so far is written in RPython - space operations, type definitions, and external C

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Amaury Forgeot d'Arc
2012/2/14 Stefan Behnel > Antonio Cuni, 14.02.2012 09:35: > > On 02/14/2012 09:17 AM, Stefan Behnel wrote: > >> > >> Stuffing the code for both CPython and PyPy into the same C source file > may > >> result in a noticeable increase in C code size at some point, but as > long > >> as the C preproc

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Stefan Behnel
Antonio Cuni, 14.02.2012 09:35: > On 02/14/2012 09:17 AM, Stefan Behnel wrote: >> >> Stuffing the code for both CPython and PyPy into the same C source file may >> result in a noticeable increase in C code size at some point, but as long >> as the C preprocessor can filter it back out, at least the

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Antonio Cuni
On 02/14/2012 09:17 AM, Stefan Behnel wrote: Stuffing the code for both CPython and PyPy into the same C source file may result in a noticeable increase in C code size at some point, but as long as the C preprocessor can filter it back out, at least the build times won't go up all that much, and

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-14 Thread Stefan Behnel
Stefan Behnel, 14.02.2012 08:46: > Antonio Cuni, 14.02.2012 00:04: >> On 02/13/2012 11:26 PM, Stefan Behnel wrote: > Last time I looked, Cython still generates code that PyPy cannot handle: > for example, it explicitly messes with tstate->curexc_type&co, > Couldn't PyErr_Fetch() and

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-13 Thread Stefan Behnel
Antonio Cuni, 14.02.2012 00:04: > On 02/13/2012 11:26 PM, Stefan Behnel wrote: >>> > Last time I looked, Cython still generates code that PyPy cannot handle: >>> > for example, it explicitly messes with tstate->curexc_type&co, >>> > Couldn't PyErr_Fetch() and PyErr_Restore() be used instead? >>

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-13 Thread mark florisson
On 13 February 2012 23:04, Antonio Cuni wrote: > On 02/13/2012 11:26 PM, Stefan Behnel wrote: >>> >>> >  Last time I looked, Cython still generates code that PyPy cannot >>> > handle: >>> >  for example, it explicitly messes with tstate->curexc_type&co, >>> >  Couldn't PyErr_Fetch() and PyErr_Rest

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-13 Thread Antonio Cuni
On 02/13/2012 11:26 PM, Stefan Behnel wrote: > Last time I looked, Cython still generates code that PyPy cannot handle: > for example, it explicitly messes with tstate->curexc_type&co, > Couldn't PyErr_Fetch() and PyErr_Restore() be used instead? Just two general comments on this, because the

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-13 Thread Stefan Behnel
Amaury Forgeot d'Arc, 13.02.2012 22:06: > 2012/2/13 Stefan Behnel > >> Given how important Cython has become for the Python ecosystem in >> many regards, it's sad that PyPy still doesn't have it available > > Last time I looked, Cython still generates code that PyPy cannot handle: > for example,

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-13 Thread Martijn Faassen
Hey, Thanks guys for bringing the discussion back on track! Regards, Martijn ___ pypy-dev mailing list pypy-dev@python.org http://mail.python.org/mailman/listinfo/pypy-dev

Re: [pypy-dev] offtopic, ontopic, ...

2012-02-13 Thread Stefan Behnel
Maciej Fijalkowski, 13.02.2012 21:41: > On Mon, Feb 13, 2012 at 9:37 PM, Stefan Behnel wrote: >> What are >> you using for comparison? speed.pypy.org? Have you noticed that amongst all >> those benchmarks there that PyPy was specifically tuned for, there is not a >> single benchmark that was select

Re: [pypy-dev] offtopic, ontopic, ... (was: ctypes - PyPy 1.8 slower than Python 2.6.5)

2012-02-13 Thread Amaury Forgeot d'Arc
2012/2/13 Stefan Behnel > Given how important Cython has become for the Python ecosystem in > many regards, it's sad that PyPy still doesn't have it available > Last time I looked, Cython still generates code that PyPy cannot handle: for example, it explicitly messes with tstate->curexc_type &co

Re: [pypy-dev] offtopic, ontopic, ... (was: ctypes - PyPy 1.8 slower than Python 2.6.5)

2012-02-13 Thread Maciej Fijalkowski
On Mon, Feb 13, 2012 at 9:37 PM, Stefan Behnel wrote: > Maciej Fijalkowski, 13.02.2012 19:44: >> On Mon, Feb 13, 2012 at 4:29 PM, Stefan Behnel wrote: >>> Sébastien Volle, 13.02.2012 13:33: My team is working on a project of fast packet sniffers and I'm comparing performance between diff

Re: [pypy-dev] offtopic, ontopic, ... (was: ctypes - PyPy 1.8 slower than Python 2.6.5)

2012-02-13 Thread Martijn Faassen
Hi Stefan, others, I've recommended to Maciej to take this discussion off-list with Stefan. I think a few mailing list etiquette mistakes were made in this discussion so far. I don't think this is worth a flame war and it's in my interest if you both work it out - Stefan's contributions added to M

[pypy-dev] offtopic, ontopic, ... (was: ctypes - PyPy 1.8 slower than Python 2.6.5)

2012-02-13 Thread Stefan Behnel
Maciej Fijalkowski, 13.02.2012 19:44: > On Mon, Feb 13, 2012 at 4:29 PM, Stefan Behnel wrote: >> Sébastien Volle, 13.02.2012 13:33: >>> My team is working on a project of fast packet sniffers and I'm comparing >>> performance between different languages. >>> So, we came up with a simple ARP sniffer