Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advertise sig_check() better in the developers manual #16902

Closed
jdemeyer opened this issue Aug 29, 2014 · 26 comments
Closed

Advertise sig_check() better in the developers manual #16902

jdemeyer opened this issue Aug 29, 2014 · 26 comments

Comments

@jdemeyer
Copy link

Component: documentation

Author: Jeroen Demeyer

Branch/Commit: 3a21668

Reviewer: Vincent Delecroix, Dima Pasechnik

Issue created by migration from https://trac.sagemath.org/ticket/16902

@jdemeyer jdemeyer added this to the sage-6.4 milestone Aug 29, 2014
@jdemeyer
Copy link
Author

Branch: u/jdemeyer/ticket/16902

@jdemeyer
Copy link
Author

Commit: 313d884

@jdemeyer
Copy link
Author

New commits:

313d884Improve sig_check() documentation

@videlec
Copy link
Contributor

videlec commented Aug 29, 2014

comment:3
  1. sig_on/sig_off is Sage specific or is it included within Cython? It would be worth mentioning it. If it is Sage specific, why is that? and how do people coding in Cython do? (seems to be with nogil). If it is shipped with Cython, there should a pointer toward its documentation.

  2. I am not sure that the following example is relevant.

def stack_sig_on():
    sig_on()
    sig_on()
    sig_on()
    # (some code)
    sig_off()
    sig_off()
    sig_off()

I mean, what would be the purpose of such code? If it is none, it is still interesting to mention it within a stack of calls like

def f1():
    sig_on()
    x = f2()
    sig_off()
    # ...

def f2():
    sig_on()
    # ...
    sig_off()
    return ans
  1. The section Releasing the Global Interpreter Lock (GIL) was a bit obscure to me. It would be nice to have one sentence to say what it is. I guess it is related to my remark 1.

  2. After reading the implementation of alarm I wonder why using alarm in doctests rather than directly the setitimer from the signal library? It is basically in TESTS blocks that such test
    would appear, and involving there the signal library is not ugly (and people reading it will learn about it instead of learning Sage wrapper!)

I learned many things reading it!
Thanks!
Vincent

@jdemeyer
Copy link
Author

comment:4

Replying to @videlec:

  1. sig_on/sig_off is Sage specific or is it included within Cython? It would be worth mentioning it. If it is Sage specific, why is that? and how do people coding in Cython do? (seems to be with nogil). If it is shipped with Cython, there should a pointer toward its documentation.

It is completely Sage-specific, I guess other people writing Cython code do not care about interrupts. There has been talking about putting these in Cython, but that has not happened yet.

  1. If it is none, it is still interesting to mention it within a stack of calls like
def f1():
    sig_on()
    x = f2()
    sig_off()
    # ...

def f2():
    sig_on()
    # ...
    sig_off()
    return ans

Good suggestion!

  1. The section Releasing the Global Interpreter Lock (GIL) was a bit obscure to me. It would be nice to have one sentence to say what it is. I guess it is related to my remark 1.

It is one of those things where, if you don't know it, you don't need to care. But I can put a link to the Cython documentation.

  1. After reading the implementation of alarm I wonder why using alarm in doctests rather than directly the setitimer from the signal library?

Because alarm() is much cleaner.

It is basically in TESTS blocks that such test
would appear, and involving there the signal library is not ugly

Why is it not ugly?

and people reading it will learn about it instead of learning Sage wrapper!

If people care about Sage's wrapper, they can still figure out the implementation and can find out about setitimer that way.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 29, 2014

Changed commit from 313d884 to 26a3edc

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 29, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

26a3edcFurther documentation fixes

@jdemeyer
Copy link
Author

New commits:

26a3edcFurther documentation fixes

@videlec
Copy link
Contributor

videlec commented Aug 29, 2014

comment:7

Nothing more to say. You can set to positive review or ask another signal newbie to reread it!

Vincent

@jdemeyer
Copy link
Author

Reviewer: Vincent Delecroix

@dimpase
Copy link
Member

dimpase commented Aug 30, 2014

comment:9

my complaint about the change is about the line

or possibly the next Python code.

this is too vague (and grammatically weird - it should better be Python statement).

Does it mean that one need reach a Python exception? Or any Python statement?
And what is the role of the word possible there? I don't get it.

@jdemeyer
Copy link
Author

comment:11

Replying to @dimpase:

it should better be Python statement.

I could change this.

Or any Python statement?
And what is the role of the word possible there? I don't get it.

I mean that Python code can sometimes raise a KeyboardInterrupt, but I also don't know exactly when this happens. For example, the following can be interrupted:

cython('while True: print "foo"')

But the following cannot be interrupted:

cython('while True: x = ["foo"] * 100')

@dimpase
Copy link
Member

dimpase commented Aug 30, 2014

comment:12

Replying to @jdemeyer:

Replying to @dimpase:

it should better be Python statement.

I could change this.

yes please.

Or any Python statement?
And what is the role of the word possible there? I don't get it.

I mean that Python code can sometimes raise a KeyboardInterrupt, but I also don't know exactly when this happens. For example, the following can be interrupted:

cython('while True: print "foo"')

But the following cannot be interrupted:

cython('while True: x = ["foo"] * 100')

Do you mean to say that Python won't be able to catch the interrupt in the former case, but not in the latter case (i.e. the latter loop will keep running)?

@jdemeyer
Copy link
Author

comment:13

Replying to @dimpase:

Replying to @jdemeyer:

Replying to @dimpase:

it should better be Python statement.

I could change this.

yes please.

Or any Python statement?
And what is the role of the word possible there? I don't get it.

I mean that Python code can sometimes raise a KeyboardInterrupt, but I also don't know exactly when this happens. For example, the following can be interrupted:

cython('while True: print "foo"')

But the following cannot be interrupted:

cython('while True: x = ["foo"] * 100')

Do you mean to say that Python won't be able to catch the interrupt in the former case, but not in the latter case (i.e. the latter loop will keep running)?

I mean that the loop in the last case will keep running because Python doesn't check for interrupts when executing x = ["foo"] * 100.

@dimpase
Copy link
Member

dimpase commented Aug 30, 2014

comment:14

Replying to @jdemeyer:

Replying to @dimpase:

Replying to @jdemeyer:

Replying to @dimpase:

it should better be Python statement.

I could change this.

yes please.

Or any Python statement?
And what is the role of the word possible there? I don't get it.

I mean that Python code can sometimes raise a KeyboardInterrupt, but I also don't know exactly when this happens. For example, the following can be interrupted:

cython('while True: print "foo"')

But the following cannot be interrupted:

cython('while True: x = ["foo"] * 100')

Do you mean to say that Python won't be able to catch the interrupt in the former case, but not in the latter case (i.e. the latter loop will keep running)?

I mean that the loop in the last case will keep running because Python doesn't check for interrupts when executing x = ["foo"] * 100.

Whereas if the next statement after the latter was also cython, it would be terminated?
Is this what you mean by possibly?

@jdemeyer
Copy link
Author

comment:15

Replying to @dimpase:

Whereas if the next statement after the latter was also cython, it would be terminated?

No, that's not what I mean. Pure Cython statements (which do not involve Python library calls) can never be interrupted.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 30, 2014

Changed commit from 26a3edc to cae4023

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Aug 30, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

cae4023Clarify that Python can also interrupt

@dimpase
Copy link
Member

dimpase commented Aug 30, 2014

Changed reviewer from Vincent Delecroix to Vincent Delecroix, Dima Pasechnik

@vbraun
Copy link
Member

vbraun commented Sep 5, 2014

comment:19
File "src/doc/en/developer/coding_in_cython.rst", line 253, in doc.en.developer.coding_in_cython
Failed example:
    cython('print "Hello"')
Expected nothing
Got:
    Hello

@jdemeyer
Copy link
Author

jdemeyer commented Sep 5, 2014

comment:20

Obviously :-)

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 5, 2014

Changed commit from cae4023 to 3a21668

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Sep 5, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

3a21668Fix silly doctest

@vbraun
Copy link
Member

vbraun commented Sep 8, 2014

Changed branch from u/jdemeyer/ticket/16902 to 3a21668

@jdemeyer
Copy link
Author

Built documentation

@jdemeyer
Copy link
Author

Attachment: coding_in_cython.html.gz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants