classification
Title: Add prime-related and number theory functions to Python
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.3
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: Ramchandra Apte, alex, benjamin.peterson, loewis, mark.dickinson, meador.inge, pitrou
Priority: normal Keywords:

Created on 2011-12-15 03:35 by Ramchandra Apte, last changed 2011-12-15 22:52 by loewis. This issue is now closed.

Messages (13)
msg149492 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2011-12-15 03:35
It would be nice to have prime-related and number theory functions in a new module or some existing module (like math).
like this:
>>> import prime
>>> prime.isprime(7)
True
>>> prime.isprime(35)
False
>>> prime.primerange(10,18)
(11,13,17)
>>> prime.isperfect(6) #Is 6 a perfect number (http://en.wikipedia.org/wiki/Perfect_number)
True
>>> prime.factorize(60)
{2:2,3:1,5:1} #2**2 * 3**1 * 5**1
msg149495 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-12-15 03:59
-1 in general. I think that's too domain specific to belong in stdlib.
msg149496 - (view) Author: Meador Inge (meador.inge) * (Python committer) Date: 2011-12-15 04:05
I agree with Benjamin about this being too domain specific for stdlib.  
Also, I don't really see a good argument as to why this functionality is 
useful.  -1 from me too.
msg149503 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2011-12-15 04:56
I think math.sin is also domain-specific.
msg149504 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-12-15 04:58
Hardly, being a widely applicable mathematical function. Also, it's in a C math library which is what Python's is originally based on.
msg149505 - (view) Author: Meador Inge (meador.inge) * (Python committer) Date: 2011-12-15 05:00
On Wed, Dec 14, 2011 at 10:58 PM, Benjamin Peterson
<report@bugs.python.org> wrote:

> Hardly, being a widely applicable mathematical function.

I was just typing a similar response.

> Also, it's in a C math library which is what Python's is originally based on.

Not just *a* C math library.  *The* Standard C library! :-)
msg149506 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-12-15 05:01
2011/12/15 Meador Inge <report@bugs.python.org>:
>
> Not just *a* C math library.  *The* Standard C library! :-)

Quite!
msg149509 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2011-12-15 05:25
Anybody else than Benjamin and Meador please comment on this.
msg149512 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-12-15 07:28
> Anybody else than Benjamin and Meador please comment on this.

I don't know why we would want to maintain this in the stdlib. We would also need a dedicated maintainer so that efficient algorithms are chosen and implemented.

Such functions are available in PyCrypto by the way: https://www.dlitz.net/software/pycrypto/doc/#crypto-util-number
msg149513 - (view) Author: Alex Gaynor (alex) * (Python committer) Date: 2011-12-15 07:30
I'll chip in my 2 cents as well and say this also seems too domain specific and not useful enough for the stdlib.
msg149514 - (view) Author: Ramchandra Apte (Ramchandra Apte) * Date: 2011-12-15 07:39
On further thought, I have changed my mind.
I think this is domain-specific.
Shall we close this bug?
msg149516 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2011-12-15 08:13
Agree with the -1s.
msg149581 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2011-12-15 22:52
maniram: the proper course is to publish such a module on PyPI. Then, if there is enough interest in it (after a few years), propose addition to the standard library.
History
Date User Action Args
2011-12-15 22:52:10loewissetnosy: + loewis
messages: + msg149581
2011-12-15 08:29:50rhettingersetstatus: languishing -> closed
resolution: rejected
2011-12-15 08:16:48Ramchandra Aptesetstatus: open -> languishing
2011-12-15 08:13:18mark.dickinsonsetmessages: + msg149516
2011-12-15 07:39:05Ramchandra Aptesetmessages: + msg149514
2011-12-15 07:30:13alexsetnosy: + alex
messages: + msg149513
2011-12-15 07:28:16pitrousetnosy: + mark.dickinson, pitrou

messages: + msg149512
versions: - Python 2.6, Python 3.1, Python 2.7, Python 3.2
2011-12-15 05:25:31Ramchandra Aptesetmessages: + msg149509
2011-12-15 05:01:30benjamin.petersonsetmessages: + msg149506
2011-12-15 05:00:49meador.ingesetmessages: + msg149505
2011-12-15 04:58:02benjamin.petersonsetmessages: + msg149504
2011-12-15 04:56:22Ramchandra Aptesetmessages: + msg149503
2011-12-15 04:05:54meador.ingesetnosy: + meador.inge
messages: + msg149496
2011-12-15 03:59:37benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg149495
2011-12-15 03:36:16Ramchandra Aptesettitle: Add prime-related functions to Python -> Add prime-related and number theory functions to Python
2011-12-15 03:35:22Ramchandra Aptecreate