[Patches] [ python-Patches-1191489 ] Simplify logic in random.py

SourceForge.net noreply at sourceforge.net
Fri Apr 29 07:42:43 CEST 2005


Patches item #1191489, was opened at 2005-04-28 14:31
Message generated for change (Comment added) made by mdehoon
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1191489&group_id=5470

Category: Library (Lib)
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Raymond Hettinger (rhettinger)
Assigned to: Martin v. Löwis (loewis)
Summary: Simplify logic in random.py

Initial Comment:
Simplify the logic in several methods for better
readability, maintainability, and speed:

* while True --> while 1
* apply de'morgan's theorem to simplify compound
conditionals
* factor out repeated test:  (p>1.0) and (p <= 1.0)
* replace pow() with **


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

Comment By: Michiel de Hoon (mdehoon)
Date: 2005-04-29 14:42

Message:
Logged In: YES 
user_id=488897

* I don't see how "while 1" is more readable than "while
True". Note also that in older Python versions, this
actually was "while 1"; it was changed to "while True" in
revision 1.39. I can't recommend changing it back.

* This pertains to line 424. I agree that the line in the
patch is more readable and perhaps faster (though marginally
so).

* I agree with you that there is a repeated test in the
current code. In the patch, I would stick with pow() instead
of ** (see my next comment)

* Unnecessary change. Some people like pow(), others like
**. I see no reason to change.

General comment: It is usually better to have different
changes in separate patches. True, the changes in the patch
all apply to random.py, but otherwise they don't have much
in common.

(I'm just a patch reviewer, not an official Python
developer, so you don't need to take my comments too seriously.)

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

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


More information about the Patches mailing list