[sage-devel] Re: Semantics of %

2009-03-13 Thread dagss
On Mar 13, 9:56 pm, "Georg S. Weber" wrote: > Hi all, > > is there already an operator named %% (double-percent)? > Somewhere in Python or its relatives? > > If not, we could have the best of both worlds. Just let act in Cython > % as the corresponding C operator, i.e. -1 % 5 == -1 (to have maxim

[sage-devel] Re: Semantics of %

2009-03-13 Thread Georg S. Weber
Hi all, is there already an operator named %% (double-percent)? Somewhere in Python or its relatives? If not, we could have the best of both worlds. Just let act in Cython % as the corresponding C operator, i.e. -1 % 5 == -1 (to have maximal speed), and let in Cython %% act as the Python % opera

[sage-devel] Re: Semantics of %

2009-03-13 Thread Jason Grout
Nick Alexander wrote: >> *plants tongue in cheek* Besides, Cython has *five* letters in common >> with Python, and only *one* letter in common with C. Clearly, that >> helps us see where the priorities should be :). > > However, all of the letters in C are the same, whereas only 5/6 of the > l

[sage-devel] Re: Semantics of %

2009-03-13 Thread Robert Bradshaw
On Mar 13, 2009, at 5:30 AM, Georg S. Weber wrote: > On 12 Mrz., 16:51, Carl Witty wrote: >> On Thu, Mar 12, 2009 at 4:16 AM, David Joyner >> wrote: >> >>> I have an ignorant question: what are the canonical reps of >>> ZZZ/nZZZ in C? (-n/2,n/2]? >>> Is the issue to decide between the interva

[sage-devel] Re: Semantics of %

2009-03-13 Thread Nick Alexander
> *plants tongue in cheek* Besides, Cython has *five* letters in common > with Python, and only *one* letter in common with C. Clearly, that > helps us see where the priorities should be :). However, all of the letters in C are the same, whereas only 5/6 of the letters in Python are the same.

[sage-devel] Re: Semantics of %

2009-03-13 Thread Robert Miller
> [X] Get -1, because they're C ints, and besides we wouldn't be using   > Cython if we didn't care about performance When I sit down to program something in Cython, I expect the ease of programming in Python, with the speed benefits of programming in C. When I'm implementing an algorithm, I'm th

[sage-devel] Re: Semantics of %

2009-03-13 Thread Jason Grout
Ryan Hinton wrote: > One more quick thought. The first sentence of the Cython tutorial > (chapter two of the manual): > > The fundamental nature of Cython can be summed up as follows: Cython is > Python with C data types. > > I understand there are thorny corner-cases and even common cases wh

[sage-devel] Re: Semantics of %

2009-03-13 Thread Ryan Hinton
One more quick thought. The first sentence of the Cython tutorial (chapter two of the manual): The fundamental nature of Cython can be summed up as follows: Cython is Python with C data types. I understand there are thorny corner-cases and even common cases where it's best to break with Pyth

[sage-devel] Re: Semantics of %

2009-03-13 Thread Carl Witty
On Fri, Mar 13, 2009 at 5:30 AM, Georg S. Weber wrote: > > > > On 12 Mrz., 16:51, Carl Witty wrote: >> On Thu, Mar 12, 2009 at 4:16 AM, David Joyner wrote: >> >> > I have an ignorant question: what are the canonical reps of >> > ZZZ/nZZZ in C? (-n/2,n/2]? >> > Is the issue to decide between the

[sage-devel] Re: Semantics of %

2009-03-13 Thread Georg S. Weber
On 12 Mrz., 16:51, Carl Witty wrote: > On Thu, Mar 12, 2009 at 4:16 AM, David Joyner wrote: > > > I have an ignorant question: what are the canonical reps of > > ZZZ/nZZZ in C? (-n/2,n/2]? > > Is the issue to decide between the interval [0,n-1] as reps of ZZ/nZZ > > (Python) > > vs (-n/2,n/2]

[sage-devel] Re: Semantics of %

2009-03-12 Thread Robert Bradshaw
On Mar 12, 2009, at 2:17 PM, Jason Grout wrote: > Craig Citro wrote: >> and be *as fast as humanly possible*. Plus, when we move things from >> Python down to Cython, we already have changes to make -- for >> instance, x**2 has to change, because C doesn't support >> exponentiation, so why would

[sage-devel] Re: Semantics of %

2009-03-12 Thread Jason Grout
Craig Citro wrote: > and be *as fast as humanly possible*. Plus, when we move things from > Python down to Cython, we already have changes to make -- for > instance, x**2 has to change, because C doesn't support > exponentiation, so why would it be any different for %? Cython doesn't automatic

[sage-devel] Re: Semantics of %

2009-03-12 Thread Nick Alexander
>> [X] Get -1, because they're C ints, and besides we wouldn't be using >> Cython if we didn't care about performance I support this because I would like Cython to remain primarily a way to interface to C code rather than become the "default language of sage". Nick --~--~-~--~~-

[sage-devel] Re: Semantics of %

2009-03-12 Thread Craig Citro
> [ ] Get 4, because it should behave just like in Python, even though > it will require extra logic and be a bit slower > > [X] Get -1, because they're C ints, and besides we wouldn't be using > Cython if we didn't care about performance > > [ ] Let the programmer decide (e.g. using http://wiki.c

[sage-devel] Re: Semantics of %

2009-03-12 Thread Carl Witty
On Thu, Mar 12, 2009 at 4:16 AM, David Joyner wrote: > > I have an ignorant question: what are the canonical reps of > ZZZ/nZZZ in C? (-n/2,n/2]? > Is the issue to decide between the interval [0,n-1] as reps of ZZ/nZZ (Python) > vs (-n/2,n/2] (C)? In C, ZZ/nZZ does not have canonical representat

[sage-devel] Re: Semantics of %

2009-03-12 Thread Ryan Hinton
Robert, Since I hit the problem I'm motivated to chime in. I also followed the email trail on the cython list. Quick summary: [X] Let the programmer decide, with [X'] Get 4 as the default There are obviously some cases where speed is paramount and others where Python compatibility is paramo

[sage-devel] Re: Semantics of %

2009-03-12 Thread David Joyner
I have an ignorant question: what are the canonical reps of ZZZ/nZZZ in C? (-n/2,n/2]? Is the issue to decide between the interval [0,n-1] as reps of ZZ/nZZ (Python) vs (-n/2,n/2] (C)? The only C book I have in my office doesn't have this and my browser seems to have some problems ("ASSERT: *** S