[Python-Dev] PEP 485 isclose() implementation review requested (original) (raw)
Christian Heimes christian at python.org
Mon May 18 01:16:13 CEST 2015
- Previous message (by thread): [Python-Dev] PEP 485 isclose() implementation review requested
- Next message (by thread): [Python-Dev] PEP 485 isclose() implementation review requested
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512
On 2015-05-18 01:02, Chris Barker wrote:
* Is there a better way to create a False or True than::
PyBoolFromLong(0) and PyBoolFromLong(1)
You can use the macros Py_RETURN_TRUE and Py_RETURN_FALSE instead of return PyBool_FromLong(0).
* Style question: should I put brackets in an if clause that has only one line?::
if (somecheck) { justthisoneexpression }
I prefer the extra brackets because they make the code more explicit. It's really a matter of taste.
* I can't find docs for PyDocSTRVAR: but it looks like it should use it -- how?
PyDoc_STRVAR(functionname_doc,
"isclose(foo) -> bool\n
\n
long doc string.");
* I'm getting a warning in my PyMethodDef clause::
static PyMethodDef IsCloseMethods[] = { {"isclose", isclosec, METHVARARGS | METHKEYWORDS, "determine if two floating point numbers are close"}, {NULL, NULL, 0, NULL} /* Sentinel */ };
You have to type cast the function pointer to a PyCFunction here:
(PyCFunction)isclose_c
The type cast is required for KEYWORD functions and NOARGS functions.
Christian
- Previous message (by thread): [Python-Dev] PEP 485 isclose() implementation review requested
- Next message (by thread): [Python-Dev] PEP 485 isclose() implementation review requested
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]