[Python-Dev] PEP 485 isclose() implementation review requested (original) (raw)

Chris Barker chris.barker at noaa.gov
Mon May 18 17:49:52 CEST 2015


Thanks Cristian, that clears up a couple things -- got it compiling without warning.

But I also discovered that I must have not pushed the latest copy yesterday.

It's on a machine at home -- I'll push it tonight. But the copy on gitHub now is mostly good -- I think the only changes are handling the docsstrings better and some more/better tests.

-Chris

On Sun, May 17, 2015 at 4:16 PM, Christian Heimes <christian at python.org> wrote:

-----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 PyRETURNTRUE and PyRETURNFALSE instead of return PyBoolFromLong(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? PyDocSTRVAR(functionnamedoc, _"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)isclosec The type cast is required for KEYWORD functions and NOARGS functions. Christian

--

Christopher Barker, Ph.D. Oceanographer

Emergency Response Division NOAA/NOS/OR&R (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker at noaa.gov -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20150518/d490b2dc/attachment.html>



More information about the Python-Dev mailing list