SteveB | 17 Jun 2012 19:34
Picon

Cython -a flag (to generate yellow-shaded HTML) without command line

(copied from http://stackoverflow.com/questions/11058933/cython-a-flag-to-generate-yellow-shaded-html-without-command-line )

When you run from the command prompt "cython -a ..." you get a really nice HTML file with yellow shading to indicate slow python operations vs fast C operations. You also get this same HTML file as a link every time you compile Cython code in Sage. My questions are: (1) Can I get this HTML file if I'm compiling using distutils? (2) Can I get this HTML file if I'm compiling using pyximport? Thanks in advance!!

Stefan Behnel | 17 Jun 2012 19:45
Picon
Favicon

Re: Cython -a flag (to generate yellow-shaded HTML) without command line

SteveB, 17.06.2012 19:34:
> (copied from 
>
http://stackoverflow.com/questions/11058933/cython-a-flag-to-generate-yellow-shaded-html-without-command-line 
> )
> 
> When you run from the command prompt "cython -a ..." you get a really nice 
> HTML file with yellow shading to indicate slow python operations vs fast C 
> operations. You also get this same HTML file as a link every time you 
> compile Cython code in Sage. My questions are: (1) Can I get this HTML file 
> if I'm compiling using distutils?

Yes, pass "annotate=True" into cythonize().

> (2) Can I get this HTML file if I'm 
> compiling using pyximport? Thanks in advance!!

I don't think there's a direct option for that in pyximport, but you can
always import Cython yourself and set the option globally in the Options
module.

Stefan

Ian Bell | 17 Jun 2012 20:41
Picon

Re: Cython -a flag (to generate yellow-shaded HTML) without command line



On Sun, Jun 17, 2012 at 10:45 AM, Stefan Behnel <stefan_ml <at> behnel.de> wrote:
SteveB, 17.06.2012 19:34:
> (copied from
> http://stackoverflow.com/questions/11058933/cython-a-flag-to-generate-yellow-shaded-html-without-command-line
> )
>
> When you run from the command prompt "cython -a ..." you get a really nice
> HTML file with yellow shading to indicate slow python operations vs fast C
> operations. You also get this same HTML file as a link every time you
> compile Cython code in Sage. My questions are: (1) Can I get this HTML file
> if I'm compiling using distutils?

Yes, pass "annotate=True" into cythonize().

Or if not using cythonize(), you can set the flag 

Cython.Compiler.Options.annotate = True

which is not documented anywhere as far as I can see

SteveB | 18 Jun 2012 01:07
Picon

Re: Cython -a flag (to generate yellow-shaded HTML) without command line

Thanks! I put up those answers at stackoverflow in case anyone else is searching for it. http://stackoverflow.com/questions/11058933/cython-a-flag-to-generate-yellow-shaded-html-without-command-line


On Sunday, June 17, 2012 2:41:43 PM UTC-4, Ian Bell wrote:



On Sun, Jun 17, 2012 at 10:45 AM, Stefan Behnel wrote:
SteveB, 17.06.2012 19:34:
> (copied from
> http://stackoverflow.com/questions/11058933/cython-a-flag-to-generate-yellow-shaded-html-without-command-line
> )
>
> When you run from the command prompt "cython -a ..." you get a really nice
> HTML file with yellow shading to indicate slow python operations vs fast C
> operations. You also get this same HTML file as a link every time you
> compile Cython code in Sage. My questions are: (1) Can I get this HTML file
> if I'm compiling using distutils?

Yes, pass "annotate=True" into cythonize().

Or if not using cythonize(), you can set the flag 

Cython.Compiler.Options.annotate = True

which is not documented anywhere as far as I can see

John Tyree | 5 Dec 2012 20:01
Picon
Gravatar

Re: Cython -a flag (to generate yellow-shaded HTML) without command line

When I was digging through the source on Github, it seemed to me that you should be able to pass cython_directives={"annontate": True} as kwarg in Cython.distutils.Extension, but when I tried it it didn't work. Any thoughts?


-John

Le dimanche 17 juin 2012 20:41:43 UTC+2, Ian Bell a écrit :


On Sun, Jun 17, 2012 at 10:45 AM, Stefan Behnel <stef... <at> behnel.de> wrote:
SteveB, 17.06.2012 19:34:
> (copied from
> http://stackoverflow.com/questions/11058933/cython-a-flag-to-generate-yellow-shaded-html-without-command-line
> )
>
> When you run from the command prompt "cython -a ..." you get a really nice
> HTML file with yellow shading to indicate slow python operations vs fast C
> operations. You also get this same HTML file as a link every time you
> compile Cython code in Sage. My questions are: (1) Can I get this HTML file
> if I'm compiling using distutils?

Yes, pass "annotate=True" into cythonize().

Or if not using cythonize(), you can set the flag 

Cython.Compiler.Options.annotate = True

which is not documented anywhere as far as I can see

Bradley Froehle | 6 Dec 2012 18:26
Picon
Gravatar

Re: Cython -a flag (to generate yellow-shaded HTML) without command line

I've gotten it to work by using `ext_modules = cythonize(..., annotate=True)` as shown on  http://docs.cython.org/src/reference/compilation.html

On Wednesday, December 5, 2012 11:01:19 AM UTC-8, John Tyree wrote:
When I was digging through the source on Github, it seemed to me that you should be able to pass cython_directives={"annontate": True} as kwarg in Cython.distutils.Extension, but when I tried it it didn't work. Any thoughts?

-John

Le dimanche 17 juin 2012 20:41:43 UTC+2, Ian Bell a écrit :


On Sun, Jun 17, 2012 at 10:45 AM, Stefan Behnel <stef... <at> behnel.de> wrote:
SteveB, 17.06.2012 19:34:
> (copied from
> http://stackoverflow.com/questions/11058933/cython-a-flag-to-generate-yellow-shaded-html-without-command-line
> )
>
> When you run from the command prompt "cython -a ..." you get a really nice
> HTML file with yellow shading to indicate slow python operations vs fast C
> operations. You also get this same HTML file as a link every time you
> compile Cython code in Sage. My questions are: (1) Can I get this HTML file
> if I'm compiling using distutils?

Yes, pass "annotate=True" into cythonize().

Or if not using cythonize(), you can set the flag 

Cython.Compiler.Options.annotate = True

which is not documented anywhere as far as I can see

John Tyree | 7 Dec 2012 13:55
Picon
Gravatar

Re: Cython -a flag (to generate yellow-shaded HTML) without command line

Yes that does work. I was just wondering about the Extension class specifically. I suppose in the end it doesn't matter. I should probably just use "cythonize" anyway.

Le jeudi 6 décembre 2012 18:26:36 UTC+1, Bradley Froehle a écrit :

I've gotten it to work by using `ext_modules = cythonize(..., annotate=True)` as shown on  http://docs.cython.org/src/reference/compilation.html

On Wednesday, December 5, 2012 11:01:19 AM UTC-8, John Tyree wrote:
When I was digging through the source on Github, it seemed to me that you should be able to pass cython_directives={"annontate": True} as kwarg in Cython.distutils.Extension, but when I tried it it didn't work. Any thoughts?

-John

Le dimanche 17 juin 2012 20:41:43 UTC+2, Ian Bell a écrit :


On Sun, Jun 17, 2012 at 10:45 AM, Stefan Behnel <stef... <at> behnel.de> wrote:
SteveB, 17.06.2012 19:34:
> (copied from
> http://stackoverflow.com/questions/11058933/cython-a-flag-to-generate-yellow-shaded-html-without-command-line
> )
>
> When you run from the command prompt "cython -a ..." you get a really nice
> HTML file with yellow shading to indicate slow python operations vs fast C
> operations. You also get this same HTML file as a link every time you
> compile Cython code in Sage. My questions are: (1) Can I get this HTML file
> if I'm compiling using distutils?

Yes, pass "annotate=True" into cythonize().

Or if not using cythonize(), you can set the flag 

Cython.Compiler.Options.annotate = True

which is not documented anywhere as far as I can see

Bradley Froehle | 7 Dec 2012 20:07
Picon
Gravatar

Re: Cython -a flag (to generate yellow-shaded HTML) without command line

Fundamentally the distutils Extension class doesn't know anything about Cython unless you use the Cython provided build_ext command.  I've found its usually easier to use cythonize which processes the pyx source and returns an Extension that distutils knows how to process.


Only drawback is that the pyx -> c conversion is run, even if you do something like `python setup.py clean`.

On Friday, December 7, 2012 4:55:32 AM UTC-8, John Tyree wrote:
Yes that does work. I was just wondering about the Extension class specifically. I suppose in the end it doesn't matter. I should probably just use "cythonize" anyway.

Le jeudi 6 décembre 2012 18:26:36 UTC+1, Bradley Froehle a écrit :
I've gotten it to work by using `ext_modules = cythonize(..., annotate=True)` as shown on  http://docs.cython.org/src/reference/compilation.html
Robert Bradshaw | 7 Dec 2012 20:12
Picon

Re: Cython -a flag (to generate yellow-shaded HTML) without command line

On Fri, Dec 7, 2012 at 11:07 AM, Bradley Froehle <brad.froehle <at> gmail.com> wrote:
> Fundamentally the distutils Extension class doesn't know anything about
> Cython unless you use the Cython provided build_ext command.  I've found its
> usually easier to use cythonize which processes the pyx source and returns
> an Extension that distutils knows how to process.
>
> Only drawback is that the pyx -> c conversion is run, even if you do
> something like `python setup.py clean`.

A patch solving this issue would be very welcome! (I'm not sure the
best way to detect this...)

> On Friday, December 7, 2012 4:55:32 AM UTC-8, John Tyree wrote:
>>
>> Yes that does work. I was just wondering about the Extension class
>> specifically. I suppose in the end it doesn't matter. I should probably just
>> use "cythonize" anyway.
>>
>> Le jeudi 6 décembre 2012 18:26:36 UTC+1, Bradley Froehle a écrit :
>>>
>>> I've gotten it to work by using `ext_modules = cythonize(...,
>>> annotate=True)` as shown on
>>> http://docs.cython.org/src/reference/compilation.html


Gmane