Opened 6 years ago
Closed 6 years ago
#13803 closed enhancement (wontfix)
Python binding to limits.h
Reported by: | vdelecroix | Owned by: | jason |
---|---|---|---|
Priority: | major | Milestone: | sage-duplicate/invalid/wontfix |
Component: | misc | Keywords: | limits, C datatype |
Cc: | sstarosta | Merged in: | |
Authors: | Reviewers: | Leif Leonhardy, Vincent Delecroix | |
Report Upstream: | N/A | Work issues: | |
Branch: | Commit: | ||
Dependencies: | Stopgaps: |
Description
Prior to #12224 we need to know what C types limits. The patch provides a direct Python access to limits.h.
Attachments (1)
Change History (12)
Changed 6 years ago by
comment:1 Changed 6 years ago by
- Status changed from new to needs_review
comment:2 Changed 6 years ago by
- Cc sstarosta added
comment:3 Changed 6 years ago by
comment:4 Changed 6 years ago by
P.S.: In the docstrings, I'd typeset the C types monospaced, e.g. ``unsigned long int``
.
comment:5 Changed 6 years ago by
- Reviewers set to Leif Leonhardy
- Status changed from needs_review to needs_work
P.P.S.:
LLONG_*
and ULLONG_*
of course require C99, so you have to add extra_compile_args = ['-std=c99']
to the module_list.py
entry. (There are systems on which GCC does not default to -std=gnu99
.)
comment:6 Changed 6 years ago by
Thanks very much (I am not at all a specialist but I need to call char_max() in some constructor).
Is the following a safe test ?
sage: from sage.misc.limits import int_min sage: int_min() # random (architecture and platform dependence) -2147483648 sage: import sysconfig sage: s = sysconfig.get_config_var('SIZEOF_INT') sage: int_min() == - 2**(s*8-1) True
Best, Vincent
comment:7 Changed 6 years ago by
It seems that this would be a valuable upstream Cython contribution as well.
In fact, isn't this it? https://github.com/cython/cython/blob/master/Cython/Includes/libc/limits.pxd
Maybe this patch would be cleaner if you did:
from libc cimport limits
at the top and then used limits.<whatever>? Or maybe not. It's a suggestion.
comment:8 follow-up: ↓ 9 Changed 6 years ago by
It seems that #12224 doesn't require this, nor does it seem needed since it's in Cython as Jason mentioned.
comment:9 in reply to: ↑ 8 Changed 6 years ago by
- Milestone changed from sage-5.10 to sage-duplicate/invalid/wontfix
comment:10 Changed 6 years ago by
- Reviewers changed from Leif Leonhardy to Leif Leonhardy, Vincent Delecroix
- Status changed from needs_work to positive_review
comment:11 Changed 6 years ago by
- Resolution set to wontfix
- Status changed from positive_review to closed
s/Mimimum/Minimum/
(once)s/a C long long max/a C long long int/
Not sure whether the doctests make sense when they're all tagged
# random
...We also have things like
sys.maxint
, a couple of (size-related) definitions fromdistutils.sysconfig.get_config_var[s]()
, andos.sysconf()
.The values don't vary much on the platforms supported by Sage; AFAIK there are currently only differences depending on whether we're on a 32- or 64-bit operating system, or, more precisely, whether Sage was built 32-bit or 64-bit (as one could in principle run a 32-bit binary dist on a 64-bit OS, or even build and run a 32-bit version on a 64-bit OS, e.g. Solaris). It would IMHO make sense to get a doctest error in case some results are unexpected.