Re: [Cython] Fused types don't work with cdef classes?

2013-02-13 Thread Stefan Behnel
Dave Hirschfeld, 13.02.2013 09:16: > Robert Bradshaw writes: >> Yes, this is a bug; there is a bad interaction between fused types and >> special methods. >> >> I created http://trac.cython.org/cython_trac/ticket/802 >> > > Thanks for following up. My actual use-case was to allow either 1D or 2D >

Re: [Cython] Fused types don't work with cdef classes?

2013-02-13 Thread Dave Hirschfeld
Robert Bradshaw writes: > > Yes, this is a bug; there is a bad interaction between fused types and > special methods. > > I created http://trac.cython.org/cython_trac/ticket/802 > Thanks for following up. My actual use-case was to allow either 1D or 2D MemoryView inputs to a function by simpl

Re: [Cython] Fused types don't work with cdef classes?

2013-02-13 Thread Robert Bradshaw
Yes, this is a bug; there is a bad interaction between fused types and special methods. I created http://trac.cython.org/cython_trac/ticket/802 On Fri, Feb 8, 2013 at 8:54 AM, Dave Hirschfeld wrote: > Is this a bug? > The following code fails to compile on windows VS2012, 32bit Python2.7 with a

[Cython] Fused types don't work with cdef classes?

2013-02-08 Thread Dave Hirschfeld
Is this a bug? The following code fails to compile on windows VS2012, 32bit Python2.7 with a recent 0.19-pre github cython: cimport cython ctypedef fused char_or_float: cython.char cython.float cdef class FusedExample: def __init__(self, char_or_float x): pass # Resu

Re: [Cython] Fused types syntax

2011-06-03 Thread Dag Sverre Seljebotn
On 06/02/2011 11:51 PM, Robert Bradshaw wrote: On Thu, Jun 2, 2011 at 2:42 PM, mark florisson wrote: On 2 June 2011 23:31, Robert Bradshaw wrote: On Thu, Jun 2, 2011 at 2:18 PM, Dag Sverre Seljebotn wrote: On 06/02/2011 06:39 PM, Robert Bradshaw wrote: In looking at merging fused types,

Re: [Cython] Fused types syntax

2011-06-02 Thread Robert Bradshaw
On Thu, Jun 2, 2011 at 2:42 PM, mark florisson wrote: > On 2 June 2011 23:31, Robert Bradshaw wrote: >> On Thu, Jun 2, 2011 at 2:18 PM, Dag Sverre Seljebotn >> wrote: >>> On 06/02/2011 06:39 PM, Robert Bradshaw wrote: In looking at merging fused types, it's time to nail down the syntax

Re: [Cython] Fused types syntax

2011-06-02 Thread mark florisson
On 2 June 2011 23:31, Robert Bradshaw wrote: > On Thu, Jun 2, 2011 at 2:18 PM, Dag Sverre Seljebotn > wrote: >> On 06/02/2011 06:39 PM, Robert Bradshaw wrote: >>> >>> In looking at merging fused types, it's time to nail down the syntax. >>> The current implementation is >>> >>>     ctypedef cytho

Re: [Cython] Fused types syntax

2011-06-02 Thread Robert Bradshaw
On Thu, Jun 2, 2011 at 2:18 PM, Dag Sverre Seljebotn wrote: > On 06/02/2011 06:39 PM, Robert Bradshaw wrote: >> >> In looking at merging fused types, it's time to nail down the syntax. >> The current implementation is >> >>     ctypedef cython.fused_type(list, dict, object) fused_t >> >> This requ

Re: [Cython] Fused types syntax

2011-06-02 Thread Nathaniel Smith
On Jun 2, 2011 2:18 PM, "Dag Sverre Seljebotn" wrote: > If you only want this allowed in typedefs, then, being puristic, I think that really a "fused type" is really different from a ctypedef, and that it would warrant something like a new keyword. > > cdef fusedtype [list, dict, object] fused_t

Re: [Cython] Fused types syntax

2011-06-02 Thread Dag Sverre Seljebotn
On 06/02/2011 06:39 PM, Robert Bradshaw wrote: In looking at merging fused types, it's time to nail down the syntax. The current implementation is ctypedef cython.fused_type(list, dict, object) fused_t This requires an addition to the grammer to allow the "call" syntax in a type declaratio

Re: [Cython] Fused types syntax

2011-06-02 Thread Robert Bradshaw
On Thu, Jun 2, 2011 at 1:07 PM, mark florisson wrote: > On 2 June 2011 18:39, Robert Bradshaw wrote: >> In looking at merging fused types, it's time to nail down the syntax. >> The current implementation is >> >>    ctypedef cython.fused_type(list, dict, object) fused_t >> >> This requires an add

Re: [Cython] Fused types syntax

2011-06-02 Thread mark florisson
On 2 June 2011 18:39, Robert Bradshaw wrote: > In looking at merging fused types, it's time to nail down the syntax. > The current implementation is > >    ctypedef cython.fused_type(list, dict, object) fused_t > > This requires an addition to the grammer to allow the "call" syntax in > a type dec

Re: [Cython] Fused types syntax

2011-06-02 Thread Chris Colbert
Not that my opinion carriers any weight, but I'm +1 on this. On Thu, Jun 2, 2011 at 11:39 AM, Robert Bradshaw < rober...@math.washington.edu> wrote: > In looking at merging fused types, it's time to nail down the syntax. > The current implementation is > >ctypedef cython.fused_type(list, dic

[Cython] Fused types syntax

2011-06-02 Thread Robert Bradshaw
In looking at merging fused types, it's time to nail down the syntax. The current implementation is ctypedef cython.fused_type(list, dict, object) fused_t This requires an addition to the grammer to allow the "call" syntax in a type declaration, as well as special casing to make it allowed on

Re: [Cython] Fused Types

2011-05-04 Thread Greg Ewing
Dag Sverre Seljebotn wrote: The argument to the above goes that you *should* be out of luck. For instance, talking about dot products, BLAS itself has float-float and double-double, but not float-double AFAIK. Seems to me that's more because generating lots of versions of a function in C is h

Re: [Cython] Fused Types

2011-05-04 Thread Dag Sverre Seljebotn
On 05/04/2011 08:13 PM, Robert Bradshaw wrote: On Wed, May 4, 2011 at 1:47 AM, mark florisson wrote: On 4 May 2011 10:24, Dag Sverre Seljebotn wrote: On 05/04/2011 01:07 AM, Greg Ewing wrote: mark florisson wrote: cdef func(floating x, floating y): ... you get a "float, float" version,

Re: [Cython] Fused Types

2011-05-04 Thread Robert Bradshaw
On Wed, May 4, 2011 at 1:47 AM, mark florisson wrote: > On 4 May 2011 10:24, Dag Sverre Seljebotn wrote: >> On 05/04/2011 01:07 AM, Greg Ewing wrote: >>> >>> mark florisson wrote: >>> cdef func(floating x, floating y): ... you get a "float, float" version, and a "double, doubl

Re: [Cython] Fused Types

2011-05-04 Thread mark florisson
On 4 May 2011 10:24, Dag Sverre Seljebotn wrote: > On 05/04/2011 01:07 AM, Greg Ewing wrote: >> >> mark florisson wrote: >> >>> cdef func(floating x, floating y): >>> ... >>> >>> you get a "float, float" version, and a "double, double" version, but >>> not "float, double" or "double, float". >> >>

Re: [Cython] Fused Types

2011-05-04 Thread Dag Sverre Seljebotn
On 05/04/2011 01:07 AM, Greg Ewing wrote: mark florisson wrote: cdef func(floating x, floating y): ... you get a "float, float" version, and a "double, double" version, but not "float, double" or "double, float". It's hard to draw conclusions from this example because it's degenerate. You do

Re: [Cython] Fused Types

2011-05-04 Thread mark florisson
On 4 May 2011 01:07, Greg Ewing wrote: > mark florisson wrote: > >> cdef func(floating x, floating y): >>    ... >> >> you get a "float, float" version, and a "double, double" version, but >> not "float, double" or "double, float". > > It's hard to draw conclusions from this example because > it's

Re: [Cython] Fused Types

2011-05-03 Thread Robert Bradshaw
On Tue, May 3, 2011 at 4:40 PM, Greg Ewing wrote: > Dag Sverre Seljebotn wrote: > >> ctypedef fused_type(float, double) speed_t >> ctypedef fused_type(float, double) acceleration_t >> >> then you get 4 specializations. >> >> ctypedef speed_t acceleration_t >> >> I guess only 2 specializations. >>

Re: [Cython] Fused Types

2011-05-03 Thread Robert Bradshaw
On Tue, May 3, 2011 at 12:59 PM, Dag Sverre Seljebotn wrote: > On 05/03/2011 08:19 PM, Robert Bradshaw wrote: > >>> Btw we shouldn't count on pruning for the design of this, I think this >>> will >>> for a large part be used with def functions. And if you use a cdef >>> function >>> from another m

Re: [Cython] Fused Types

2011-05-03 Thread Greg Ewing
Dag Sverre Seljebotn wrote: ctypedef fused_type(float, double) speed_t ctypedef fused_type(float, double) acceleration_t then you get 4 specializations. ctypedef speed_t acceleration_t I guess only 2 specializations. Treating the typedefs in this way is slightly fishy of course. Indeed. Th

Re: [Cython] Fused Types

2011-05-03 Thread Greg Ewing
mark florisson wrote: cdef func(floating x, floating y): ... you get a "float, float" version, and a "double, double" version, but not "float, double" or "double, float". It's hard to draw conclusions from this example because it's degenerate. You don't really need multiple versions of a

Re: [Cython] Fused Types

2011-05-03 Thread Dag Sverre Seljebotn
On 05/03/2011 08:19 PM, Robert Bradshaw wrote: Btw we shouldn't count on pruning for the design of this, I think this will for a large part be used with def functions. And if you use a cdef function from another module through a pxd, you also need all versions. Well, we'll want to avoid compil

Re: [Cython] Fused Types

2011-05-03 Thread Robert Bradshaw
On Tue, May 3, 2011 at 10:06 AM, mark florisson wrote: > On 3 May 2011 18:00, Robert Bradshaw wrote: >> floating is implicitly available, we could require making it explicit. > > How would we make it explicit. Require the parameterization, i.e. floating_p[floating] would be the as-yet-unsp

Re: [Cython] Fused Types

2011-05-03 Thread Dag Sverre Seljebotn
I was wrong. We need cdef f(floating x, floating_p y) ...to get 2 specializations, not 4. And the rest follows from there. So I'm with Robert's real stance :-) I don't think we want flexibility, we want simplicity over all. You can always use a templating language. Btw we shouldn't count on p

Re: [Cython] Fused Types

2011-05-03 Thread mark florisson
On 3 May 2011 18:00, Robert Bradshaw wrote: > On Tue, May 3, 2011 at 12:59 AM, mark florisson > wrote: >> On 3 May 2011 00:21, Robert Bradshaw wrote: >>> On Mon, May 2, 2011 at 1:56 PM, mark florisson >>> wrote: On 2 May 2011 18:24, Robert Bradshaw wrote: > On Sun, May 1, 2011 at 2:38

Re: [Cython] Fused Types

2011-05-03 Thread mark florisson
On 3 May 2011 16:36, Sturla Molden wrote: > Den 03.05.2011 16:06, skrev Dag Sverre Seljebotn: >> >> Well, if you do something like >> >> ctypedef fused_type(float, double) speed_t >> ctypedef fused_type(float, double) acceleration_t >> >> cdef func(speed_t x, acceleration_t y) >> >> then you get 4

Re: [Cython] Fused Types

2011-05-03 Thread Robert Bradshaw
On Tue, May 3, 2011 at 7:06 AM, Dag Sverre Seljebotn wrote: > On 05/03/2011 03:51 PM, Stefan Behnel wrote: >> >> mark florisson, 03.05.2011 15:17: >>> >>> if you have >>> >>> cdef func(floating x, floating y): >>> ... >>> >>> you get a "float, float" version, and a "double, double" version, but >>

Re: [Cython] Fused Types

2011-05-03 Thread Robert Bradshaw
On Tue, May 3, 2011 at 12:59 AM, mark florisson wrote: > On 3 May 2011 00:21, Robert Bradshaw wrote: >> On Mon, May 2, 2011 at 1:56 PM, mark florisson >> wrote: >>> On 2 May 2011 18:24, Robert Bradshaw wrote: On Sun, May 1, 2011 at 2:38 AM, mark florisson wrote: > A remaining iss

Re: [Cython] Fused Types

2011-05-03 Thread Sturla Molden
Den 03.05.2011 16:06, skrev Dag Sverre Seljebotn: Well, if you do something like ctypedef fused_type(float, double) speed_t ctypedef fused_type(float, double) acceleration_t cdef func(speed_t x, acceleration_t y) then you get 4 specializations. Each new typedef gives a new polymorphic type.

Re: [Cython] Fused Types

2011-05-03 Thread Dag Sverre Seljebotn
On 05/03/2011 03:51 PM, Stefan Behnel wrote: mark florisson, 03.05.2011 15:17: if you have cdef func(floating x, floating y): ... you get a "float, float" version, and a "double, double" version, but not "float, double" or "double, float". So, what would you have to do in order to get a "flo

Re: [Cython] Fused Types

2011-05-03 Thread Stefan Behnel
mark florisson, 03.05.2011 15:17: if you have cdef func(floating x, floating y): ... you get a "float, float" version, and a "double, double" version, but not "float, double" or "double, float". So, what would you have to do in order to get a "float, double" and "double, float" version

Re: [Cython] Fused Types

2011-05-03 Thread mark florisson
On 3 May 2011 15:17, mark florisson wrote: > On 3 May 2011 07:47, Greg Ewing wrote: >> I'm a bit confused about how fused types combine to >> create further fused types. If you have something >> like >> >>  ctypedef struct Vector: >>    floating x >>    floating y >>    floating z >> >> then is i

Re: [Cython] Fused Types

2011-05-03 Thread mark florisson
On 3 May 2011 07:47, Greg Ewing wrote: > I'm a bit confused about how fused types combine to > create further fused types. If you have something > like > >  ctypedef struct Vector: >    floating x >    floating y >    floating z > > then is it going to generate code for all possible > combinations

Re: [Cython] Fused Types

2011-05-03 Thread Greg Ewing
I'm a bit confused about how fused types combine to create further fused types. If you have something like ctypedef struct Vector: floating x floating y floating z then is it going to generate code for all possible combinations of types for x, y and z? That's probably not what the

Re: [Cython] Fused Types

2011-05-03 Thread mark florisson
On 3 May 2011 10:57, Dag Sverre Seljebotn wrote: > On 05/03/2011 10:49 AM, mark florisson wrote: >> >> On 3 May 2011 10:44, Dag Sverre Seljebotn >>  wrote: >>> >>> On 05/03/2011 10:42 AM, mark florisson wrote: On 3 May 2011 10:07, Dag Sverre Seljebotn  wrote: > > On 05/03/20

Re: [Cython] Fused Types

2011-05-03 Thread Dag Sverre Seljebotn
On 05/03/2011 10:49 AM, mark florisson wrote: On 3 May 2011 10:44, Dag Sverre Seljebotn wrote: On 05/03/2011 10:42 AM, mark florisson wrote: On 3 May 2011 10:07, Dag Sverre Seljebotn wrote: On 05/03/2011 09:59 AM, mark florisson wrote: On 3 May 2011 00:21, Robert Bradshaw wrote: On

Re: [Cython] Fused Types

2011-05-03 Thread mark florisson
On 3 May 2011 10:44, Dag Sverre Seljebotn wrote: > On 05/03/2011 10:42 AM, mark florisson wrote: >> >> On 3 May 2011 10:07, Dag Sverre Seljebotn >>  wrote: >>> >>> On 05/03/2011 09:59 AM, mark florisson wrote: On 3 May 2011 00:21, Robert Bradshaw  wrote: > > On Mon, May 2, 2

Re: [Cython] Fused Types

2011-05-03 Thread Dag Sverre Seljebotn
On 05/03/2011 10:42 AM, mark florisson wrote: On 3 May 2011 10:07, Dag Sverre Seljebotn wrote: On 05/03/2011 09:59 AM, mark florisson wrote: On 3 May 2011 00:21, Robert Bradshawwrote: On Mon, May 2, 2011 at 1:56 PM, mark florisson wrote: On 2 May 2011 18:24, Robert Bradshaw wrot

Re: [Cython] Fused Types

2011-05-03 Thread mark florisson
On 3 May 2011 10:07, Dag Sverre Seljebotn wrote: > On 05/03/2011 09:59 AM, mark florisson wrote: >> >> On 3 May 2011 00:21, Robert Bradshaw  wrote: >>> >>> On Mon, May 2, 2011 at 1:56 PM, mark florisson >>>  wrote: On 2 May 2011 18:24, Robert Bradshaw  wrote: > > On Sun, Ma

Re: [Cython] Fused Types

2011-05-03 Thread Dag Sverre Seljebotn
On 05/03/2011 09:59 AM, mark florisson wrote: On 3 May 2011 00:21, Robert Bradshaw wrote: On Mon, May 2, 2011 at 1:56 PM, mark florisson wrote: On 2 May 2011 18:24, Robert Bradshaw wrote: On Sun, May 1, 2011 at 2:38 AM, mark florisson wrote: A remaining issue which I'm not quite certain

Re: [Cython] Fused Types

2011-05-03 Thread mark florisson
On 3 May 2011 00:21, Robert Bradshaw wrote: > On Mon, May 2, 2011 at 1:56 PM, mark florisson > wrote: >> On 2 May 2011 18:24, Robert Bradshaw wrote: >>> On Sun, May 1, 2011 at 2:38 AM, mark florisson >>> wrote: A remaining issue which I'm not quite certain about is the specialization

Re: [Cython] Fused Types

2011-05-02 Thread Robert Bradshaw
On Mon, May 2, 2011 at 1:56 PM, mark florisson wrote: > On 2 May 2011 18:24, Robert Bradshaw wrote: >> On Sun, May 1, 2011 at 2:38 AM, mark florisson >> wrote: >>> A remaining issue which I'm not quite certain about is the >>> specialization through subscripts, e.g. func[double]. How should this

Re: [Cython] Fused Types

2011-05-02 Thread mark florisson
On 2 May 2011 18:24, Robert Bradshaw wrote: > On Sun, May 1, 2011 at 2:38 AM, mark florisson > wrote: >> On 30 April 2011 09:51, Dag Sverre Seljebotn >> wrote: >>> On 04/30/2011 08:39 AM, Robert Bradshaw wrote: On Fri, Apr 29, 2011 at 3:53 AM, mark florisson  wrote: > >

Re: [Cython] Fused Types

2011-05-02 Thread Robert Bradshaw
On Sun, May 1, 2011 at 2:38 AM, mark florisson wrote: > On 30 April 2011 09:51, Dag Sverre Seljebotn > wrote: >> On 04/30/2011 08:39 AM, Robert Bradshaw wrote: >>> >>> On Fri, Apr 29, 2011 at 3:53 AM, mark florisson >>>  wrote: On 29 April 2011 12:28, Pauli Virtanen  wrote: >

Re: [Cython] Fused Types

2011-05-02 Thread Dag Sverre Seljebotn
On 05/02/2011 03:00 PM, Sturla Molden wrote: Den 02.05.2011 11:15, skrev Dag Sverre Seljebotn: I.e., your question is very vague. Ok, what I wanted to ask was "why have one syntax for interfacing C++ templates and another for generics?" It seems like syntax bloat to me. You're welcome to d

Re: [Cython] Fused Types

2011-05-02 Thread Dag Sverre Seljebotn
On 05/02/2011 03:00 PM, Sturla Molden wrote: Den 02.05.2011 11:15, skrev Dag Sverre Seljebotn: I.e., your question is very vague. Ok, what I wanted to ask was "why have one syntax for interfacing C++ templates and another for generics?" It seems like syntax bloat to me. But we do that. The

Re: [Cython] Fused Types

2011-05-02 Thread Sturla Molden
Den 02.05.2011 11:15, skrev Dag Sverre Seljebotn: I.e., your question is very vague. Ok, what I wanted to ask was "why have one syntax for interfacing C++ templates and another for generics?" It seems like syntax bloat to me. You're welcome to draft your own proposal for full-blown templat

Re: [Cython] Fused Types

2011-05-02 Thread mark florisson
On 2 May 2011 12:32, Stefan Behnel wrote: > mark florisson, 02.05.2011 11:22: >> >> On 2 May 2011 11:08, Stefan Behnel wrote: >>> >>> Robert Bradshaw, 30.04.2011 08:16: On Fri, Apr 29, 2011 at 8:04 AM, mark florisson > > With the type matching it matches on exactly 'if src_type i

Re: [Cython] Fused Types

2011-05-02 Thread Stefan Behnel
mark florisson, 02.05.2011 11:22: On 2 May 2011 11:08, Stefan Behnel wrote: Robert Bradshaw, 30.04.2011 08:16: On Fri, Apr 29, 2011 at 8:04 AM, mark florisson With the type matching it matches on exactly 'if src_type is dst_type:' so you can't use 'and' and such... perhaps I should turn thes

Re: [Cython] Fused Types

2011-05-02 Thread mark florisson
On 2 May 2011 11:08, Stefan Behnel wrote: > Robert Bradshaw, 30.04.2011 08:16: >> >> On Fri, Apr 29, 2011 at 8:04 AM, mark florisson >>> >>> With the type matching it matches on exactly 'if src_type is >>> dst_type:' so you can't use 'and' and such... perhaps I should turn >>> these expression int

Re: [Cython] Fused Types

2011-05-02 Thread Dag Sverre Seljebotn
On 05/01/2011 06:25 PM, Sturla Molden wrote: Den 01.05.2011 16:36, skrev Stefan Behnel: Not everyone uses C++. And the C++ compiler cannot adapt the code to specific Python object types. Ok, that makes sence. Second question: Why not stay with the current square-bracket syntax? Does Cython n

Re: [Cython] Fused Types

2011-05-02 Thread Stefan Behnel
Robert Bradshaw, 30.04.2011 08:16: On Fri, Apr 29, 2011 at 8:04 AM, mark florisson With the type matching it matches on exactly 'if src_type is dst_type:' so you can't use 'and' and such... perhaps I should turn these expression into a node with the constant value first and then see if the resul

Re: [Cython] Fused Types

2011-05-01 Thread Stefan Behnel
Sturla Molden, 01.05.2011 18:25: I'd also think duck types could be specialised from run-time information? (Cf. profile-guided optimisation.) Interesting. That could even be much simpler than WPA. Basically, the profiler would dump the argument types it sees, and then generate a .pxd file wit

Re: [Cython] Fused Types

2011-05-01 Thread Sturla Molden
Den 01.05.2011 16:36, skrev Stefan Behnel: Not everyone uses C++. And the C++ compiler cannot adapt the code to specific Python object types. Ok, that makes sence. Second question: Why not stay with the current square-bracket syntax? Does Cython need a fused-type in addition? I'd also thi

Re: [Cython] Fused Types

2011-05-01 Thread Stefan Behnel
Sturla Molden, 01.05.2011 15:29: Den 01.05.2011 02:24, skrev Greg Ewing: Stefan Behnel wrote: Meaning, we'd find a new type during type analysis or inference, split off a new version of the function and then analyse it. I'm not sure that this degree of smartness would really be a good idea. I

Re: [Cython] Fused Types

2011-05-01 Thread Sturla Molden
Den 01.05.2011 02:24, skrev Greg Ewing: Stefan Behnel wrote: Meaning, we'd find a new type during type analysis or inference, split off a new version of the function and then analyse it. I'm not sure that this degree of smartness would really be a good idea. I'd worry that if I made a type err

Re: [Cython] Fused Types

2011-05-01 Thread mark florisson
On 30 April 2011 09:51, Dag Sverre Seljebotn wrote: > On 04/30/2011 08:39 AM, Robert Bradshaw wrote: >> >> On Fri, Apr 29, 2011 at 3:53 AM, mark florisson >>  wrote: >>> >>> On 29 April 2011 12:28, Pauli Virtanen  wrote: No, just that real_t is specialized to float whenever struct_t is

Re: [Cython] Fused Types

2011-04-30 Thread Greg Ewing
Stefan Behnel wrote: Meaning, we'd find a new type during type analysis or inference, split off a new version of the function and then analyse it. I'm not sure that this degree of smartness would really be a good idea. I'd worry that if I made a type error somewhere, the compiler would go off

Re: [Cython] Fused Types

2011-04-30 Thread Robert Bradshaw
On Sat, Apr 30, 2011 at 7:24 AM, Stefan Behnel wrote: > Robert Bradshaw, 29.04.2011 06:32: >> >> On Thu, Apr 28, 2011 at 7:09 PM, Stefan Behnel >>  wrote: >>> >>> mark florisson, 28.04.2011 23:29: On 28 April 2011 22:31, mark florisson wrote: > > On 28 April 2011 22:12, Robert Br

Re: [Cython] Fused Types

2011-04-30 Thread Robert Bradshaw
On Sat, Apr 30, 2011 at 12:51 AM, Dag Sverre Seljebotn wrote: > On 04/30/2011 08:39 AM, Robert Bradshaw wrote: >> >> On Fri, Apr 29, 2011 at 3:53 AM, mark florisson >>  wrote: >>> >>> On 29 April 2011 12:28, Pauli Virtanen  wrote: No, just that real_t is specialized to float whenever st

Re: [Cython] Fused Types

2011-04-30 Thread Stefan Behnel
Robert Bradshaw, 29.04.2011 06:32: On Thu, Apr 28, 2011 at 7:09 PM, Stefan Behnel wrote: mark florisson, 28.04.2011 23:29: On 28 April 2011 22:31, mark florisson wrote: On 28 April 2011 22:12, Robert Bradshaw wrote: On Thu, Apr 28, 2011 at 12:48 PM, mark florisson wrote: So I fixed all

Re: [Cython] Fused Types

2011-04-30 Thread Dag Sverre Seljebotn
On 04/30/2011 08:39 AM, Robert Bradshaw wrote: On Fri, Apr 29, 2011 at 3:53 AM, mark florisson wrote: On 29 April 2011 12:28, Pauli Virtanen wrote: No, just that real_t is specialized to float whenever struct_t is specialized to A and to double when B. Or a more realistic example, c

Re: [Cython] Fused Types

2011-04-29 Thread Robert Bradshaw
On Fri, Apr 29, 2011 at 3:53 AM, mark florisson wrote: > On 29 April 2011 12:28, Pauli Virtanen wrote: >> Fri, 29 Apr 2011 11:30:19 +0200, mark florisson wrote: >>> On 29 April 2011 11:03, Pauli Virtanen wrote: >> [clip] Are you planning to special-case the "real_t complex" syntax? Shooting

Re: [Cython] Fused Types

2011-04-29 Thread Robert Bradshaw
On Fri, Apr 29, 2011 at 8:04 AM, mark florisson wrote: > On 29 April 2011 06:32, Robert Bradshaw wrote: >> On Thu, Apr 28, 2011 at 7:09 PM, Stefan Behnel wrote: >>> mark florisson, 28.04.2011 23:29: On 28 April 2011 22:31, mark florisson wrote: > > On 28 April 2011 22:12, Rober

Re: [Cython] Fused Types

2011-04-29 Thread Pauli Virtanen
Fri, 29 Apr 2011 16:59:22 +0200, mark florisson wrote: [clip] > Hmm, indeed, it's pretty weird. I'm fine with the pairing also, although > I'm still not sure how common this case is, and if we really want to > support it. Wouldn't good old C promotion work for this? e.g. if the > type is either flo

Re: [Cython] Fused Types

2011-04-29 Thread mark florisson
On 29 April 2011 06:32, Robert Bradshaw wrote: > On Thu, Apr 28, 2011 at 7:09 PM, Stefan Behnel wrote: >> mark florisson, 28.04.2011 23:29: >>> >>> On 28 April 2011 22:31, mark florisson wrote: On 28 April 2011 22:12, Robert Bradshaw wrote: > > On Thu, Apr 28, 2011 at 12:48 PM,

Re: [Cython] Fused Types

2011-04-29 Thread mark florisson
On 29 April 2011 13:37, Pauli Virtanen wrote: > Fri, 29 Apr 2011 12:53:06 +0200, mark florisson wrote: > [clip] >> But if we just allow that for fused types, then couldn't we simply do >> >> ctypedef cython.fused_type(float, double) real_t >> >> cdef real_plus_one(real_t complex a): >>     real_t

Re: [Cython] Fused Types

2011-04-29 Thread Pauli Virtanen
Fri, 29 Apr 2011 12:53:06 +0200, mark florisson wrote: [clip] > But if we just allow that for fused types, then couldn't we simply do > > ctypedef cython.fused_type(float, double) real_t > > cdef real_plus_one(real_t complex a): > real_t b = a.real > return b + 1 > > ? Then you don't nee

Re: [Cython] Fused Types

2011-04-29 Thread Dag Sverre Seljebotn
On 04/29/2011 12:53 PM, mark florisson wrote: On 29 April 2011 12:28, Pauli Virtanen wrote: Fri, 29 Apr 2011 11:30:19 +0200, mark florisson wrote: On 29 April 2011 11:03, Pauli Virtanen wrote: [clip] Are you planning to special-case the "real_t complex" syntax? Shooting from the sidelines,

Re: [Cython] Fused Types

2011-04-29 Thread mark florisson
On 29 April 2011 12:28, Pauli Virtanen wrote: > Fri, 29 Apr 2011 11:30:19 +0200, mark florisson wrote: >> On 29 April 2011 11:03, Pauli Virtanen wrote: > [clip] >>> Are you planning to special-case the "real_t complex" syntax? Shooting >>> from the sidelines, one more generic solution might be, e

Re: [Cython] Fused Types

2011-04-29 Thread Pauli Virtanen
Fri, 29 Apr 2011 11:30:19 +0200, mark florisson wrote: > On 29 April 2011 11:03, Pauli Virtanen wrote: [clip] >> Are you planning to special-case the "real_t complex" syntax? Shooting >> from the sidelines, one more generic solution might be, e.g., > > I'm sorry, I'm not sure what syntax you are

Re: [Cython] Fused Types

2011-04-29 Thread mark florisson
On 29 April 2011 11:03, Pauli Virtanen wrote: > Fri, 29 Apr 2011 10:23:55 +0200, mark florisson wrote: > [clip] >> Ok, branching on the type sounds fine to me. It brings one problem >> though: because you cannot declare the variables of your variable type >> (the type of say, mystruct.attrib), you

Re: [Cython] Fused Types

2011-04-29 Thread Pauli Virtanen
Fri, 29 Apr 2011 10:23:55 +0200, mark florisson wrote: [clip] > Ok, branching on the type sounds fine to me. It brings one problem > though: because you cannot declare the variables of your variable type > (the type of say, mystruct.attrib), you will need to do multiple > declarations outside of yo

Re: [Cython] Fused Types

2011-04-29 Thread mark florisson
On 29 April 2011 06:32, Robert Bradshaw wrote: > On Thu, Apr 28, 2011 at 7:09 PM, Stefan Behnel wrote: >> mark florisson, 28.04.2011 23:29: >>> >>> On 28 April 2011 22:31, mark florisson wrote: On 28 April 2011 22:12, Robert Bradshaw wrote: > > On Thu, Apr 28, 2011 at 12:48 PM,

Re: [Cython] Fused Types

2011-04-29 Thread mark florisson
On 28 April 2011 23:59, Robert Bradshaw wrote: > On Thu, Apr 28, 2011 at 2:29 PM, mark florisson > wrote: >> On 28 April 2011 22:31, mark florisson wrote: >>> On 28 April 2011 22:12, Robert Bradshaw >>> wrote: On Thu, Apr 28, 2011 at 12:48 PM, mark florisson wrote: > So I f

Re: [Cython] Fused Types

2011-04-29 Thread mark florisson
On 28 April 2011 23:30, Robert Bradshaw wrote: > On Thu, Apr 28, 2011 at 1:31 PM, mark florisson > wrote: >> On 28 April 2011 22:12, Robert Bradshaw wrote: >>> On Thu, Apr 28, 2011 at 12:48 PM, mark florisson >>> wrote: >>> So I fixed all that, but I'm currently wondering about the propose

Re: [Cython] Fused Types

2011-04-28 Thread Robert Bradshaw
On Thu, Apr 28, 2011 at 7:09 PM, Stefan Behnel wrote: > mark florisson, 28.04.2011 23:29: >> >> On 28 April 2011 22:31, mark florisson wrote: >>> >>> On 28 April 2011 22:12, Robert Bradshaw wrote: On Thu, Apr 28, 2011 at 12:48 PM, mark florisson wrote: > So I fixed all that, but

Re: [Cython] Fused Types

2011-04-28 Thread Stefan Behnel
mark florisson, 28.04.2011 23:29: On 28 April 2011 22:31, mark florisson wrote: On 28 April 2011 22:12, Robert Bradshaw wrote: On Thu, Apr 28, 2011 at 12:48 PM, mark florisson wrote: So I fixed all that, but I'm currently wondering about the proposed cython.typeof(). I believe it currently re

Re: [Cython] Fused Types

2011-04-28 Thread Robert Bradshaw
On Thu, Apr 28, 2011 at 2:29 PM, mark florisson wrote: > On 28 April 2011 22:31, mark florisson wrote: >> On 28 April 2011 22:12, Robert Bradshaw wrote: >>> On Thu, Apr 28, 2011 at 12:48 PM, mark florisson >>> wrote: >>> So I fixed all that, but I'm currently wondering about the proposed >

Re: [Cython] Fused Types

2011-04-28 Thread Robert Bradshaw
On Thu, Apr 28, 2011 at 1:31 PM, mark florisson wrote: > On 28 April 2011 22:12, Robert Bradshaw wrote: >> On Thu, Apr 28, 2011 at 12:48 PM, mark florisson >> wrote: >> >>> So I fixed all that, but I'm currently wondering about the proposed >>> cython.typeof(). I believe it currently returns a s

Re: [Cython] Fused Types

2011-04-28 Thread mark florisson
On 28 April 2011 22:31, mark florisson wrote: > On 28 April 2011 22:12, Robert Bradshaw wrote: >> On Thu, Apr 28, 2011 at 12:48 PM, mark florisson >> wrote: >> >>> So I fixed all that, but I'm currently wondering about the proposed >>> cython.typeof(). I believe it currently returns a string wit

Re: [Cython] Fused Types

2011-04-28 Thread mark florisson
On 28 April 2011 22:12, Robert Bradshaw wrote: > On Thu, Apr 28, 2011 at 12:48 PM, mark florisson > wrote: > >> So I fixed all that, but I'm currently wondering about the proposed >> cython.typeof(). I believe it currently returns a string with the type >> name, and not the type itself. > > Yes.

Re: [Cython] Fused Types

2011-04-28 Thread Robert Bradshaw
On Thu, Apr 28, 2011 at 12:48 PM, mark florisson wrote: > So I fixed all that, but I'm currently wondering about the proposed > cython.typeof(). I believe it currently returns a string with the type > name, and not the type itself. Yes. This is just because there's not really anything better to

Re: [Cython] Fused Types

2011-04-28 Thread mark florisson
On 28 April 2011 22:10, mark florisson wrote: > On 28 April 2011 21:58, Stefan Behnel wrote: >> mark florisson, 28.04.2011 21:48: >>> >>> I'm currently wondering about the proposed >>> cython.typeof(). I believe it currently returns a string with the type >>> name, and not the type itself. So I t

Re: [Cython] Fused Types

2011-04-28 Thread mark florisson
On 28 April 2011 21:58, Stefan Behnel wrote: > mark florisson, 28.04.2011 21:48: >> >> I'm currently wondering about the proposed >> cython.typeof(). I believe it currently returns a string with the type >> name, and not the type itself. So I think it would be inconsistent to >> suddenly start all

Re: [Cython] Fused Types

2011-04-28 Thread Stefan Behnel
mark florisson, 28.04.2011 21:48: I'm currently wondering about the proposed cython.typeof(). I believe it currently returns a string with the type name, and not the type itself. So I think it would be inconsistent to suddenly start allowing comparison with 'is' and 'isinstance' and such. I'm al

Re: [Cython] Fused Types

2011-04-28 Thread mark florisson
On 26 April 2011 20:05, Robert Bradshaw wrote: > On Tue, Apr 26, 2011 at 8:18 AM, mark florisson > wrote: >> On 26 April 2011 16:43, Stefan Behnel wrote: >>> mark florisson, 26.04.2011 16:23: I've been working a bit on fused types (http://wiki.cython.org/enhancements/fusedtypes),

Re: [Cython] Fused Types

2011-04-26 Thread Stefan Behnel
mark florisson, 26.04.2011 17:18: On 26 April 2011 16:43, Stefan Behnel wrote: mark florisson, 26.04.2011 16:23: I've been working a bit on fused types (http://wiki.cython.org/enhancements/fusedtypes), and I've got it to generate code for every permutation of specific types. Currently it only

Re: [Cython] Fused Types

2011-04-26 Thread Robert Bradshaw
On Tue, Apr 26, 2011 at 8:18 AM, mark florisson wrote: > On 26 April 2011 16:43, Stefan Behnel wrote: >> mark florisson, 26.04.2011 16:23: >>> >>> I've been working a bit on fused types >>> (http://wiki.cython.org/enhancements/fusedtypes), and I've got it to >>> generate code for every permutatio

Re: [Cython] Fused Types

2011-04-26 Thread mark florisson
On 26 April 2011 16:43, Stefan Behnel wrote: > mark florisson, 26.04.2011 16:23: >> >> I've been working a bit on fused types >> (http://wiki.cython.org/enhancements/fusedtypes), and I've got it to >> generate code for every permutation of specific types. Currently it >> only works for cdef functi

Re: [Cython] Fused Types

2011-04-26 Thread Stefan Behnel
mark florisson, 26.04.2011 16:23: I've been working a bit on fused types (http://wiki.cython.org/enhancements/fusedtypes), and I've got it to generate code for every permutation of specific types. Currently it only works for cdef functions. Now in SimpleCallNode I'm trying to use PyrexTypes.best_

[Cython] Fused Types

2011-04-26 Thread mark florisson
Hey, I've been working a bit on fused types (http://wiki.cython.org/enhancements/fusedtypes), and I've got it to generate code for every permutation of specific types. Currently it only works for cdef functions. Now in SimpleCallNode I'm trying to use PyrexTypes.best_match() to find the function w