[Python-ideas] Re: Add the imath module

2020-03-22 Thread Chris Angelico
On Mon, Mar 23, 2020 at 5:13 AM Neil Girdhar wrote: > > I mean: > > def binom(n, *ks): > # Check that there is at least one ki, and that their sum is less than n, > and that they are all nonnegative. > # Returns n! / (prod(ki! for ki in ks) * (n-sum(ks))!) > > This would still work for bi

[Python-ideas] Re: Add the imath module

2020-03-22 Thread Neil Girdhar
I mean: def binom(n, *ks): # Check that there is at least one ki, and that their sum is less than n, and that they are all nonnegative. # Returns n! / (prod(ki! for ki in ks) * (n-sum(ks))!) This would still work for binom(n, k), but would also work for the mulinomial case. On Sunday,

[Python-ideas] Re: Add the imath module

2020-03-22 Thread Neil Girdhar
I really like this idea. It fixes the weirdness whereby cmath is for complex numbers, and math is for real numbers and integers. I like separating them into three categories. One suggestion: Consider generalizing binom to the multinomial coefficent. def binom(n, *ks): # Returns n! / prod(

[Python-ideas] Re: Add the imath module

2020-03-21 Thread Steven D'Aprano
On Sat, Mar 21, 2020 at 04:18:32PM +, Jonathan Fine wrote: > Hi > > In https://bugs.python.org/issue40028 , > Ross Rhodes suggested adding to the standard library a function that finds > the prime factors of a non-negative integer. So far as I know, any gen

[Python-ideas] Re: Add the imath module

2020-03-21 Thread Jonathan Fine
Hi In https://bugs.python.org/issue40028 , Ross Rhodes suggested adding to the standard library a function that finds the prime factors of a non-negative integer. So far as I know, any general algorithm for doing this requires a list of prime numbers. To this

[Python-ideas] Re: Add the imath module

2020-03-21 Thread Ross
Hello Serhiy, I support this proposal, thanks for sharing this thread in my enhancement proposal (issue #40028). I would be more than happy to help you where time permits in implementing this module if approval is granted. Ross ___ Python-ideas mailin

[Python-ideas] Re: Add the imath module

2020-03-21 Thread Ross
I support this proposal. This would fit nicely with my recent enhancement proposal raised to introduce a method for finding prime factors of non-negative integer n. ___ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to