[Patches] [ python-Patches-652930 ] math.log(x [,base])

noreply@sourceforge.net noreply@sourceforge.net
Sat, 14 Dec 2002 09:34:22 -0800


Patches item #652930, was opened at 2002-12-12 16:26
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=652930&group_id=5470

Category: Modules
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Raymond Hettinger (rhettinger)
Assigned to: Nobody/Anonymous (nobody)
Summary: math.log(x [,base])

Initial Comment:
Added an optional base argument to math.log().

Inspired by a request to help@python.org.


----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2002-12-14 12:34

Message:
Logged In: YES 
user_id=80475

* Deallocated num object on den failure
* Added bracketed text to \versionchanged

I appreciate the quick and thorough reviews.

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-12-14 02:37

Message:
Logged In: YES 
user_id=21627

I'm sorry for be that picky, but ... This version loses the
num object into garbage if computation of the den object fails.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2002-12-14 00:42

Message:
Logged In: YES 
user_id=80475

New patch attached.
* removed re-use of newargs tuple
* used PyTuple_SET_ITEM
* trapped potential error exits


----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-12-13 10:36

Message:
Logged In: YES 
user_id=21627

This still missing a number of potential error exits: the 
Tuple_New can fail (as could have the BuildValue), and the 
loghelpers can fail.

On the second SetItem, please add a comment that mutating 
the tuple is fine.

Potentially, the Divide can also fail, but that probably won't 
matter.

----------------------------------------------------------------------

Comment By: Raymond Hettinger (rhettinger)
Date: 2002-12-13 10:24

Message:
Logged In: YES 
user_id=80475

Revised patch attached.

* Now, only one call to ParseTuple
* Used PyTuple_New instead of Py_BuildValue
* Added \versionchanged{} mark-up

----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-12-13 05:55

Message:
Logged In: YES 
user_id=21627

I think you should avoid the triple calls to ParseTuple, and 
the intermediate BuildValue call. AFAICT, the ParseTuple in 
loghelper can *only* fail if there is not exactly one argument 
(since it won't care about its type); atleast for log, you made 
it impossible that the argument count is incorrect. For log10, 
making the function a METH_O can do that test.

Building a tuple from an object with BuildValue also seems 
overkill, using PyTuple_New is just as simple.

Please use the \versionchanged (or \versionadded) markup to 
document that the parameter is new to 2.3.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=652930&group_id=5470