Find your next open-source project

Search by name, purpose, or keyword — or paste a GitHub repository URL

TheAlgorithms/Python

Learning Resources

Python implementations of classic algorithms and data structures, intended as a reading and study resource for learners.

226,041
51,299
Python
MIT
10 years old

What It Is

TheAlgorithms/Python is a community-maintained collection of algorithms and data structures written in Python for education. It covers areas such as searching, sorting, graph algorithms, ciphers, and more, organized into directories and indexed by an algorithm directory. The code is meant for reading and learning, not as a drop-in replacement for the Python standard library; the README explicitly notes that implementations may be less efficient than standard-library equivalents.

Getting Started

  1. Browse the algorithm directory to locate the topic you want to study.
  2. Clone the repository (or open it in Gitpod via the badge in the README), then open the relevant .py file in your editor.
  3. Run a file to observe its behavior, for example:
python path/to/algorithm.py

Many files include tests or example calls at the bottom. Follow the contribution guidelines if you want to submit changes, and use the Discord community for questions. There is also a project website that provides browsing and search over the implementations.

Constraints

The README states that implementations are for learning purposes only and may be less efficient than standard-library versions. Community reviews from 2018 raised concrete quality problems: a commenter reported that Dijkstra's algorithm did not use a priority queue and that both Dijkstra and Prim had a hard-coded maximum distance of 100000 review comment; another pointed out incorrect complexity analysis for a Trie implementation reply; and others criticized the code style as non-Pythonic and noted an unrelated ebook file stored in the ciphers folder, later explained as a benchmark input discussion. Treat individual files as examples to read critically rather than authoritative reference code, and check current file contents before relying on an implementation.

The project uses the MIT license, Python, and CI workflows with pre-commit and Ruff formatting workflow.

HotRepo's take

The repository appeared on the Python daily list on 2026-11-12 at position 13 with 41 stars gained that day, and earlier Hacker News threads from 2018–2024 drew limited but recurring attention. The most substantive discussion, from September 2018, was critical of algorithm correctness and code quality thread, with commenters arguing the collection is better understood as newcomers submitting practice implementations than as a curated learning reference reply. That history makes the project useful as a large catalog of Python algorithm examples to inspect and discuss, but not as a source of vetted, production-quality implementations.

Written by AI from the project's README, updated . The project's own docs are the source of truth.

Hacker News

Algorithms Implemented in Python
▲ 153 · 27 comments · September 22, 2018
Algorithms Implemented in Python
▲ 6 · 0 comments · November 25, 2020
All Algorithms Implemented in Python
▲ 5 · 0 comments · June 14, 2022