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 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 yellow a line is, the slower it will probably run because it is
> doing more python stuff than just straight C stuff.  Some python stuff
> is unavoidable, though, like the def statement above.
>
> Note that the coloring of the lines is heuristic; it's not a guarantee
> that those lines are the ones that are running slowly.  But it does  
> help
> quite a bit if you want to speed up your code: make sure that the  
> inner
> loops don't have very much yellow in them.

Yep. The color of a line is proportional to (or at least an  
increasing function of) the number of times the Python C API is  
invoked. Pure white should be 100% C. As Jason mentioned, it is  
important to note that yellow does not necessarily mean slow, simply  
that there's lots of implicit stuff going on that's often not obvious  
by looking at the code (and is very helpful in caching stuff like  
unnecessary coercions due to forgetting to cdef a variable).

> Personally, I think the coloring of the lines and the ability to click
> on them is one of the neatest features about developing cython in the
> notebook.

Thanks :). From the command line you can run cython -a.

- Robert


--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to