Open-source project
TheAlgorithms/Python avatar
TheAlgorithms/Python

TheAlgorithms/Python: a study repository of algorithms that asks for Python 3.15

All Algorithms implemented in Python

226,114 stars51,323 forksPythonMIT

At a glance

What is it?
TheAlgorithms/Python collects hand-written algorithm implementations in topic folders for people learning how they work. It is reading material with a modern toolchain, not a library, and its pyproject.toml sets a Python 3.15 floor.
Who is it for?
Use TheAlgorithms/Python if you are studying how an algorithm is built, or want to contribute one, and you already run Python 3.15. Do not import it or vendor it into production code: the README says the implementations may be less efficient than the standard library, and there is no release to pin.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 1 day ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 14, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • TheAlgorithms/Python226,114 ★ · +2,283
Star history
Repository2026-08-182026-11-14
TheAlgorithms/Python223.8k226.1k

2,283 Stars in the last 88 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

Topic folders at the repository root, with DIRECTORY.md as the index

Every algorithm in TheAlgorithms/Python lives in a folder named after its topic, placed directly at the repository root. Sorting code sits in sorts/, search routines in searches/, graph algorithms in graphs/, and dynamic programming in dynamic_programming/. Next to those are folders that stretch the word algorithm well past a textbook syllabus: ciphers/, hashes/, data_compression/, fuzzy_logic/, quantum/, financial/, physics/, electronics/ and project_euler/. There is no package hierarchy to learn before reading. You open the folder for the topic and read the file.

Finding a specific routine goes through DIRECTORY.md, which the README names as the overview of the whole collection. A rendered site is published at https://thealgorithms.github.io/Python/, and the repository carries a docs/ folder plus a docs dependency group with sphinx, sphinx-autoapi and myst-parser. The audience is people working through how an algorithm is put together in Python, and contributors who want to add one. Engineers shopping for a dependency to import are not that audience, and the README says as much in its first sentence of prose.

Written to be read, and slower than the standard library by its own admission

The one substantive warning in the README settles most adoption questions: "Implementations are for learning purposes only. They may be less efficient than the implementations in the Python standard library. Use them at your discretion." A merge sort in sorts/ is there so you can follow the recursion. It is not there to replace list.sort in a service.

Copying a file into production means taking on code whose priority is clarity, with no release process behind it and no stated performance target. The standard library is the honest alternative, and the difference in approach is plain. sorted, list.sort, heapq and bisect ship with CPython and are maintained as part of the interpreter; they are what the README compares itself against. This repository shows how such a routine can be written by hand, while the standard library is what you call.

For numeric and statistical work outside the standard library, the project declares numpy, scipy, scikit-learn and statsmodels as its own dependencies. Those packages are the production route for the topics covered in machine_learning/ or linear_algebra/.

pyproject.toml sets the floor at Python 3.15

Check your interpreter before cloning. pyproject.toml declares requires-python = ">=3.15", the classifiers list Python 3.15 and nothing older, and the ruff configuration sets target-version = "py315". A .python-version file sits at the root too. For a reader on an earlier release the consequence is direct: an installer that honours requires-python will refuse the project, so the test suite and the shared dependency set are out of reach until you upgrade. Opening a single file to read it still works, and for many visitors reading is the whole point.

The classifiers also include "Programming Language :: Python :: Free Threading :: 2 - Beta". The project targets the free-threaded build of CPython alongside the regular one. That is an unusual commitment for an educational repository, and it has a visible cost in the dependency file, covered in the OpenCV section below.

No release and no install line: you work from the master branch

TheAlgorithms/Python has no GitHub releases, and the README contains no install command. Its Getting Started section asks you to read CONTRIBUTING.md before contributing, and nothing more. Getting the code means taking it from the GitHub repository, whose default branch is master, or opening it in a hosted workspace: the README links a Gitpod workspace, and the root holds both .gitpod.yml and a .devcontainer/ folder for a containerised setup.

The package metadata you are working against is minimal:

toml
[project]
name = "thealgorithms-python"
version = "0.0.1"
description = "TheAlgorithms in Python"
authors = [ { name = "TheAlgorithms Contributors" } ]
requires-python = ">=3.15"

The version has stayed a placeholder, so nothing marks a stable point on master. A fork or vendored copy has to record the commit it was taken from. The last push was on 2026-11-02, so the branch is moving. Optional extras come as dependency groups: test adds pytest and pytest-cov, docs adds the Sphinx toolchain, and a group called euler-validate adds httpx2 and numpy.

opencv-python is parked in an optional cv group because of free-threaded builds

One dependency was moved out of the main list on purpose:

toml
cv = [
  "opencv-python>=4.10.0.84",
]

The comment above it in pyproject.toml gives the reason. opencv-python has no free-threaded (cp315t) wheel yet and fails to build from source under 3.15t because of CMake, which blocked uv sync for every CI job. Moving it into an optional group lets the free-threaded CI install everything else and run pytest-run-parallel on the pure-Python algorithms.

The cost lands on you. A plain project install does not bring OpenCV, so any file that imports it fails with an import error until you add the cv group. On a free-threaded 3.15t interpreter you cannot add it at all until a cp315t wheel ships. The comment tracks the upstream issue as opencv/opencv#27933 and says the group will be folded back into the core dependencies once that wheel exists.

Reading one sort still pulls in a data science dependency set

There is a single [project] dependencies list for the whole repository, not one per folder. Someone who came for binary search gets the same environment as someone running the machine learning code: numpy, pandas, scipy, scikit-learn, statsmodels, sympy, matplotlib, cython, pillow and imageio, plus beautifulsoup4 and lxml for HTML parsing, httpx2, fake-useragent, rich and typing-extensions.

That design keeps one environment valid for every folder, which is convenient for CI and for contributors who touch several topics. For a reader it means a heavy install for one short function. The workaround is to skip the project install and run a single file from sorts/ or searches/ with a bare 3.15 interpreter, accepting that nothing has checked its imports for you. Files that import numpy or pandas will not run that way.

ruff, pre-commit and pytest decide what gets merged

Contributions pass through tooling that is stricter than the educational framing suggests. The README badges point to GitHub Actions, pre-commit and the ruff formatter, and .pre-commit-config.yaml sits at the root. The ruff lint.select list in pyproject.toml includes A (flake8-builtins), ANN (flake8-annotations), ARG, ASYNC, B (flake8-bugbear), BLE, C4, C90 (McCabe cyclomatic complexity), DTZ and E, with output-format = "full". A submitted function without type annotations, or one whose branching exceeds the complexity check, gets flagged before review. The tests/ folder and the test dependency group carry the pytest side.

CONTRIBUTING.md is the required reading before a pull request, an AGENTS.md file at the root follows the convention for instructions aimed at coding agents, and questions go to the project Discord. SECURITY.md is present as well. The code is under the MIT license, so copied files can be reused in other projects as long as the copyright and permission notice travels with them.

Editorial conclusion

Use TheAlgorithms/Python if you are studying how an algorithm is built, or want to contribute one, and you already run Python 3.15. Do not import it or vendor it into production code: the README says the implementations may be less efficient than the standard library, and there is no release to pin. Before running anything, confirm your interpreter satisfies requires-python >=3.15 and check whether the file you want imports OpenCV, which sits in the optional cv group.

Frequently asked questions

Can I use TheAlgorithms/Python code in production?

The README says the implementations are for learning purposes only and may be less efficient than the implementations in the Python standard library. It leaves their use at your discretion, and there are no tagged releases to pin.

Which Python version does TheAlgorithms/Python require?

pyproject.toml sets requires-python to >=3.15 and ruff targets py315. The classifiers also mark free-threading support as beta.

How do I install TheAlgorithms/Python?

The README gives no install command and the repository has no GitHub releases. You take the code from the master branch on GitHub, or open it in the linked Gitpod workspace or the .devcontainer setup.

Where is the full list of algorithms in TheAlgorithms/Python?

The README points to DIRECTORY.md for an overview of every algorithm. A rendered site is also published at https://thealgorithms.github.io/Python/.

Official sources

  1. Official documentation
  2. Official README
  3. Project repository
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/thealgorithms-python.svg)](https://hysenlabs.com/projects/thealgorithms-python)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/thealgorithms-python.svg)](https://hysenlabs.com/projects/thealgorithms-python)

Was this useful?