[issue2138] Factorial

2008-02-23 Thread Anders Valind
Anders Valind added the comment: Yeah, I like the idea of a third party module and letting the popularity and quality decide when/if it will be included. This would also make it easier to see what kind of functionality people would want. __ Tracker <[EMAIL PROT

[issue2138] Factorial

2008-02-23 Thread Mark Dickinson
Mark Dickinson added the comment: The trouble is that this comes at a time when people are trying to trim the standard library down rather than enlarge it. Perhaps the solution is a high-quality third party 'imath' module? If/when it gets to a stage where lots of people are using it, it could

[issue2138] Factorial

2008-02-22 Thread Anders Valind
Anders Valind added the comment: IMHO, The best place to put functions such as xgcd, factorial, etc, would be a new imath module, an integer equivalent of cmath. Not only would it keep the standard math module clean, it would also make clear that these functions are for integers only. -

[issue2138] Factorial

2008-02-22 Thread ajaksu
ajaksu added the comment: Would it be implemented in C? How about using Luschny's Prime Swing (http://www.luschny.de/math/factorial/FastFactorialFunctions.htm and http://www.luschny.de/math/factorial/Benchmark.html )? -- nosy: +ajaksu2 __ Tracker <[EMAIL

[issue2138] Factorial

2008-02-21 Thread paul rubin
paul rubin added the comment: I like the idea of having some integer math functions like this in the stdlib; whether in the math module or elsewhere doesn't matter much. In particular I remember having to implement xgcd on several separate occasions for unrelated applications, each time requirin

[issue2138] Factorial

2008-02-19 Thread David Albert Torpey
David Albert Torpey added the comment: Mr. Dickinson thank you for doing this. I do not know how to help with a patch. If it helps, here is the code I use in python: def factorial(n, _known=[1]): assert isinstance(n, int), "Need an integer. This isn't a gamma" assert n >= 0, "Sorry, c

[issue2138] Factorial

2008-02-18 Thread Raymond Hettinger
Raymond Hettinger added the comment: I wouldn't worry about that so much -- our job is to provide good primitives. __ Tracker <[EMAIL PROTECTED]> __ ___

[issue2138] Factorial

2008-02-18 Thread Mark Dickinson
Mark Dickinson added the comment: The other issue here is that I see factorial as being the thin end of the wedge. If factorial were implemented, it would probably only be on the order of minutes before people wanted to know where the binomial() function was. So it seems to me that either t

[issue2138] Factorial

2008-02-18 Thread Raymond Hettinger
Raymond Hettinger added the comment: gcd() is probably fine where it is. People learn about GCD and LCM where they first learn fractions. So, there is a strong association. __ Tracker <[EMAIL PROTECTED]> __

[issue2138] Factorial

2008-02-18 Thread Mark Dickinson
Mark Dickinson added the comment: > Since the domain and range are ints/longs, this makes more sense as a > method on than as a math module function. Fair enough. Raymond, do you have any thoughts on where a gcd implementation might most usefully live? Should it stay in fractions.py, or is

[issue2138] Factorial

2008-02-18 Thread Raymond Hettinger
Raymond Hettinger added the comment: Since the domain and range are ints/longs, this makes more sense as a method on than as a math module function. The other math module functions mostly have real valued inputs and mostly have counterparts in cmath. IIRC, Tim wanted the math module to ma

[issue2138] Factorial

2008-02-18 Thread Mark Dickinson
Mark Dickinson added the comment: > Should there be some upper limit on the argument math.factorial would take? I'd say not. Any such limit would be artificial, and an arbitrary choice. Just let the natural time and space requirements be the limiting factor. __

[issue2138] Factorial

2008-02-18 Thread Alan McIntyre
Alan McIntyre added the comment: >Except that hypot is not a one-liner, if you want to get edge cases right. Ah, true; thanks for pointing that out. Should there be some upper limit on the argument math.factorial would take? At the moment I can't think of any reason for picking a given limit,

[issue2138] Factorial

2008-02-18 Thread Mark Dickinson
Mark Dickinson added the comment: > Yeah, it's a one-liner, but so is hypot Except that hypot is not a one-liner, if you want to get edge cases right. (Consider hypot(1e200, 1e200), or hypot(1e-200, 1e-200).) __ Tracker <[EMAIL PROTECTED]>

[issue2138] Factorial

2008-02-18 Thread Mark Dickinson
Mark Dickinson added the comment: I don't think it would be appropriate to add this as a method of int; it seems like unnecessary clutter on a core type. Perhaps a math.factorial function could be considered? Historically, the math module has just been a way to wrap the (mostly floating-point)

[issue2138] Factorial

2008-02-18 Thread Alan McIntyre
Alan McIntyre added the comment: It seems like most of the methods on integers are for two-argument operations (add, mul, div, etc.), while a lot of single-argument operations are in the math module. If this gets added would it fit better as a function in the math module? I have to say a factor

[issue2138] Factorial

2008-02-18 Thread David Albert Torpey
New submission from David Albert Torpey: Add a factorial method. Everybody understands what it means before they are out of high school and it comes up all the time in statistics and combinatorics. Ruby has a factorial method and heck even basic calculators have a factorial key. print n.fac