Re: [sage-support] Re: Optimizing this function with Cython

2014-03-16 Thread Georgios Tzanakis
On Sun, Mar 16, 2014 at 12:01 AM, Robert Bradshaw rober...@math.washington.edu wrote: On Fri, Mar 14, 2014 at 2:03 PM, Georgios Tzanakis gtzana...@gmail.com wrote: On Fri, Mar 14, 2014 at 4:49 PM, Robert Bradshaw rober...@math.washington.edu wrote: Note that intL[i][introws[i]]

Re: [sage-support] Re: Optimizing this function with Cython

2014-03-15 Thread Robert Bradshaw
On Fri, Mar 14, 2014 at 2:03 PM, Georgios Tzanakis gtzana...@gmail.com wrote: On Fri, Mar 14, 2014 at 4:49 PM, Robert Bradshaw rober...@math.washington.edu wrote: Note that intL[i][introws[i]] + j %w == 0: would probably be just (or nearly) as fast as ((int(tupleL[i])[int(rows[i])])+j

Re: [sage-support] Re: Optimizing this function with Cython

2014-03-14 Thread Robert Bradshaw
Note that intL[i][introws[i]] + j %w == 0: would probably be just (or nearly) as fast as ((int(tupleL[i])[int(rows[i])])+j %w)==0 If you're going to be dealing with arrays of ints you might want to look into NumPy and/or memory views for even more speed. On Thu, Mar 13, 2014 at 7:58 PM,

Re: [sage-support] Re: Optimizing this function with Cython

2014-03-14 Thread Georgios Tzanakis
On Fri, Mar 14, 2014 at 4:49 PM, Robert Bradshaw rober...@math.washington.edu wrote: Note that intL[i][introws[i]] + j %w == 0: would probably be just (or nearly) as fast as ((int(tupleL[i])[int(rows[i])])+j %w)==0 Good to know, thanks.. If you're going to be dealing with arrays

[sage-support] Re: Optimizing this function with Cython

2014-03-13 Thread Simon King
Hi! On 2014-03-12, geo909 gtzana...@gmail.com wrote: But I'm still not sure how to use things properly. So, for instance, is the following optimization reasonable? (there is an ~30% increase in speed from pure python code) It is easy to get more. But first: Is there a bug in your code? You

Re: [sage-support] Re: Optimizing this function with Cython

2014-03-13 Thread Georgios Tzanakis
Hi Simon, I *really* appreciate your thorough answer! Indeed there was a bug and I had to do a couple of changes to the code, but I understood a lot of things about how to use Cython and was able to use it properly and have improvements. On top of that, I didn't know about the timeit function