[sage-support] Re: lists in cython

2008-09-26 Thread Robert Bradshaw
On Sep 25, 2008, at 7:06 PM, Jason Grout wrote: cesarnda wrote: why the line: def primes(int kmax): is in yellow? It's yellow because it's handling a python function call (parsing the arguments, converting a python object to an int, ...) If you click on the line, you can see the

[sage-support] Re: lists in cython

2008-09-26 Thread Simon King
On Sep 25, 6:45 pm, cesarnda [EMAIL PROTECTED] wrote: ...   result = [] ...       result.append(n) ... if I compile in the notebook I get a html file showing me the following lines in yellow: def primes(int kmax): result = [] result.append(n) return result how can I modify this

[sage-support] Re: lists in cython

2008-09-26 Thread Robert Bradshaw
On Sep 26, 2008, at 12:09 AM, Simon King wrote: On Sep 25, 6:45 pm, cesarnda [EMAIL PROTECTED] wrote: ... result = [] ... result.append(n) ... if I compile in the notebook I get a html file showing me the following lines in yellow: def primes(int kmax): result = []

[sage-support] Re: lists in cython

2008-09-26 Thread Robert Bradshaw
On Sep 25, 2008, at 3:45 PM, cesarnda wrote: in http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/ there is the following example: def primes(int kmax): cdef int n, k, i cdef int p[1000] result = [] if kmax 1000: kmax = 1000 k = 0 n = 2 while k kmax:

[sage-support] Re: lists in cython

2008-09-26 Thread cesarnda
I already did that and I get this: cdef list codeSet = [] __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_codeSet = __pyx_1; __pyx_1 = 0; and if I don't do it that way I get:

[sage-support] Re: lists in cython

2008-09-26 Thread Robert Bradshaw
On Sep 26, 2008, at 8:21 AM, cesarnda wrote: I already did that and I get this: cdef list codeSet = [] __pyx_1 = PyList_New(0); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 210; __pyx_clineno = __LINE__; goto __pyx_L1_error;} __pyx_v_codeSet = __pyx_1;

[sage-support] Re: lists in cython

2008-09-26 Thread cesarnda
Actually I wanted it less yellow, if I do that or only codeSet = [] or codeSet = ([]) the result is the same. On Sep 26, 1:43 pm, Robert Bradshaw [EMAIL PROTECTED] wrote: On Sep 26, 2008, at 8:21 AM, cesarnda wrote: I already did that and I get this:  cdef list codeSet = []  

[sage-support] Re: lists in cython

2008-09-26 Thread Robert Bradshaw
On Sep 26, 2008, at 6:04 PM, cesarnda wrote: Actually I wanted it less yellow, if I do that or only codeSet = [] or codeSet = ([]) the result is the same. You can't create a list in a less yellow way than calling PyList_New (0), and that's all its doing so you're optimal. - Robert

[sage-support] Re: lists in cython

2008-09-25 Thread cesarnda
why the line: def primes(int kmax): is in yellow? On Sep 25, 8:03 pm, Robert Bradshaw [EMAIL PROTECTED] wrote: On Sep 25, 2008, at 3:45 PM, cesarnda wrote: inhttp://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/there is the following example: def primes(int kmax):   cdef int

[sage-support] Re: lists in cython

2008-09-25 Thread Jason Grout
cesarnda wrote: why the line: def primes(int kmax): is in yellow? If you click on the line, you can see the actual C code that Cython generated for you. Doing that, you'll notice that there are quite a few more python calls stemming from yellow lines than the white lines. The more

[sage-support] Re: #if in cython?

2007-10-13 Thread William Stein
On 10/13/07, Simon King [EMAIL PROTECTED] wrote: Dear sage-supporters, a question on pyrex/cython: I have type definitions depending on an environment variable, such as #if ZZZ==zzz typedef unsigned char FEL; #elif ZZZ==bigzzz typedef unsigned short FEL; Is there a way to do a similar

[sage-support] Re: #if in cython?

2007-10-13 Thread mabshoff
On Oct 14, 2:37 am, Simon King [EMAIL PROTECTED] wrote: Dear William, you wrote: This question belongs in the cython or pyrex mailing lists, rather than sage-support, so I've forwarded it there. After posting my question, i found an answer to my question in the web: Pyrex 0.9.6