[Python-ideas] Proposal for Algorithms Library

Terry Reedy tjreedy at udel.edu
Mon Mar 4 22:59:28 CET 2013

On 3/4/2013 7:06 AM, Akshit Agarwal wrote:
> I am new to Python Community but I am using Python from around 1 year
> and I love to do coding on Python.

So do I.

> Now I want to introduce an idea that I think should be there in Python
> which is I want to start working on a *"Algorithms Library"* which would
> be containing all basic Algorithms in its Intial Phase and then we can

There is no agreed-on set of 'basic algorithms'.

Anyway, Python already includes most basic algorithms either built-in or 
in the stdlib. And the implementation may be *better* than found in any 
book. An example is timsort, available both and list.sorted and 
sorted(iterable). hash() has a carefully designed hash algorithm that 
now takes into account denial-of-service attaches. Python dicts are 
sophisticated hash tables. The itertools module has basic algorithms for 
iterables, including .product and .combinations.

Beyond this, there are thousands of third-party packages that are 
nothing but more and more algorithms.

> include all Algorithms which are listed in Introduction to Algorithms by
> CLRS and further extending to all possible algorithms which should be
> included.

There is no finite set of 'possible algorithms'. Every function is an 
algorithm, or if you prefer, implements an algorithm.

A typical algorithms text has a grab-bag of algorithms selected for 
particular didactic purposes. They usually do not form a coherent module 
or package.

Python versions of the algorithms in a particular popular book that does 
not use Python might be a useful package to put on PyPI, but I would be 
careful about copyright and intellectual property issues.

> Implementing this will be very good for Python as Algorithms are used
> everywhere and developers have to spent a lot of their time in
> implementing the common algorithms

Do you have any particular examples in mind?

Terry Jan Reedy

More information about the Python-ideas mailing list