[sage-devel] Re: Py_ssize_t question

2007-10-31 Thread Jaap Spies
Hi Michael, You wrote: > > It is, but I forgot to mention it in the other thread. The ticket has > been closed, but it would be great if you could submit the cleanup > patch for #217 in the next 36 hours. I submitted a patch bundle on trac #217, which changed back some substitutions Py_ssize_t

[sage-devel] Re: Py_ssize_t question

2007-10-31 Thread mabshoff
On Oct 31, 9:55 pm, Jaap Spies <[EMAIL PROTECTED]> wrote: > Hi Michael, > > > > > it should also be noted that the bug Carl mention above seems to be > > the root cause for #973. I am currently updating to 2.8.10 on my local > > box (which shows the segfault for dance(10)) to see if the problem

[sage-devel] Re: Py_ssize_t question

2007-10-31 Thread Jaap Spies
Hi Michael, > > it should also be noted that the bug Carl mention above seems to be > the root cause for #973. I am currently updating to 2.8.10 on my local > box (which shows the segfault for dance(10)) to see if the problem is > really fixed. I added some additional info to #973 about this. >

[sage-devel] Re: Py_ssize_t question

2007-10-31 Thread Robert Bradshaw
On Oct 30, 2007, at 7:16 PM, mabshoff wrote: > On Oct 31, 3:11 am, Carl Witty <[EMAIL PROTECTED]> wrote: >> On Oct 29, 10:11 am, Robert Bradshaw <[EMAIL PROTECTED]> >> wrote: > > Hello, > >> >>> There is another way that Py_ssize_t differs from int, namely that >>> Cython casting happens via the

[sage-devel] Re: Py_ssize_t question

2007-10-30 Thread mabshoff
On Oct 31, 3:11 am, Carl Witty <[EMAIL PROTECTED]> wrote: > On Oct 29, 10:11 am, Robert Bradshaw <[EMAIL PROTECTED]> > wrote: Hello, > > > There is another way that Py_ssize_t differs from int, namely that > > Cython casting happens via the __index__ rather than __int__ > > function. __int__ i

[sage-devel] Re: Py_ssize_t question

2007-10-30 Thread Carl Witty
On Oct 29, 10:11 am, Robert Bradshaw <[EMAIL PROTECTED]> wrote: > There is another way that Py_ssize_t differs from int, namely that > Cython casting happens via the __index__ rather than __int__ > function. __int__ is potentially bad because it tries to hard to cast > to an int (e.g. truncating,

[sage-devel] Re: Py_ssize_t question

2007-10-29 Thread Jaap Spies
William Stein wrote: > On 10/29/07, Robert Bradshaw <[EMAIL PROTECTED]> wrote: >> On Oct 28, 2007, at 4:29 PM, William Stein wrote: >>> On 10/28/07, Jaap Spies <[EMAIL PROTECTED]> wrote: What is the correct/recommended use of Py_ssize_t in Cython code? >>> You should use Py_ssize_t *anywhere*

[sage-devel] Re: Py_ssize_t question

2007-10-29 Thread Robert Bradshaw
On Oct 29, 2007, at 10:16 AM, William Stein wrote: >>> Note that it is not just size_t from C, since it is signed, >>> since in Python list indices can be negative (in which case counting >>> starts from the right side of the list). >> >> I think it is actually signed so that errors can be return

[sage-devel] Re: Py_ssize_t question

2007-10-29 Thread William Stein
On 10/29/07, Robert Bradshaw <[EMAIL PROTECTED]> wrote: > On Oct 28, 2007, at 4:29 PM, William Stein wrote: > > On 10/28/07, Jaap Spies <[EMAIL PROTECTED]> wrote: > >> What is the correct/recommended use of Py_ssize_t in Cython code? > > > > You should use Py_ssize_t *anywhere* you are indexing in

[sage-devel] Re: Py_ssize_t question

2007-10-29 Thread Robert Bradshaw
On Oct 28, 2007, at 4:29 PM, William Stein wrote: > On 10/28/07, Jaap Spies <[EMAIL PROTECTED]> wrote: >> What is the correct/recommended use of Py_ssize_t in Cython code? > > You should use Py_ssize_t *anywhere* you are indexing into a Python > list, tuple, etc. Py_ssize_t is the official Pyth

[sage-devel] Re: Py_ssize_t question

2007-10-29 Thread William Stein
On 10/29/07, Jaap Spies <[EMAIL PROTECTED]> wrote: > > Now, instead if the code working like it used to, there will be an overflow, > > and one will get total nonsense. > > > > In your example the permanent is just the product of the entries. > > You deserve to get total nonsense when you try to c

[sage-devel] Re: Py_ssize_t question

2007-10-29 Thread Jaap Spies
William Stein wrote: > On 10/28/07, Jaap Spies <[EMAIL PROTECTED]> wrote: > >> I did change some of them in trac #217, but I think a new trac >> ticket should be created. > > > Are you sure?I just had a look at trac #217, and your changing Py_ssize_t > into int specifically *introduces* bu

[sage-devel] Re: Py_ssize_t question

2007-10-29 Thread Jaap Spies
William Stein wrote: > On 10/28/07, Jaap Spies <[EMAIL PROTECTED]> wrote: >>> Py_ssize_t should *never* be used if you really mean to use an >>> int. But in any situation that you're indexing something, use >>> it. Note that it is not just size_t from C, since it is signed, >>> since in Python

[sage-devel] Re: Py_ssize_t question

2007-10-28 Thread William Stein
On 10/28/07, Jaap Spies <[EMAIL PROTECTED]> wrote: > > Py_ssize_t should *never* be used if you really mean to use an > > int. But in any situation that you're indexing something, use > > it. Note that it is not just size_t from C, since it is signed, > > since in Python list indices can be neg

[sage-devel] Re: Py_ssize_t question

2007-10-28 Thread Jaap Spies
William Stein wrote: > On 10/28/07, Jaap Spies <[EMAIL PROTECTED]> wrote: >> What is the correct/recommended use of Py_ssize_t in Cython code? > > Py_ssize_t should *never* be used if you really mean to use an > int. But in any situation that you're indexing something, use > it. Note that it

[sage-devel] Re: Py_ssize_t question

2007-10-28 Thread William Stein
On 10/28/07, Jaap Spies <[EMAIL PROTECTED]> wrote: > What is the correct/recommended use of Py_ssize_t in Cython code? You should use Py_ssize_t *anywhere* you are indexing into a Python list, tuple, etc. Py_ssize_t is the official Python 2.5.x type for indexing into such structures. Py_ssize_