Skip to main content

This project/library contains common algorithms...

Project description

core-algorithms

A Python library containing common algorithm implementations, currently focused on sorting.


Python Versions License Pipeline Status Docs Status Security

Installation

pip install core-algorithms
uv pip install core-algorithms

Features

  • Sorting algorithms: bubble sort, insertion sort, merge sort, quick sort, and selection sort

  • Fully typed: complete type annotations with py.typed marker for PEP 561 compliance

  • Broad Python support: compatible with Python 3.9 through 3.14 and PyPy

Quick Start

pip install core-algorithms
pip install -e ".[dev]"    # For development

Sorting

Import and use any of the available sorting algorithms directly:

from core_algorithms.sorting import bubble_sort, insertion_sort
from core_algorithms.sorting import merge_sort, quick_sort, selection_sort

data = [5, 3, 8, 1, 9, 2]

print(bubble_sort(data[:]))     # [1, 2, 3, 5, 8, 9]
print(insertion_sort(data[:]))  # [1, 2, 3, 5, 8, 9]
print(merge_sort(data[:]))      # [1, 2, 3, 5, 8, 9]
print(selection_sort(data[:]))  # [1, 2, 3, 5, 8, 9]

quick_sort(data)
print(data)                     # [1, 2, 3, 5, 8, 9]

Benchmark

Run the sorting benchmark to compare all implementations against Python’s built-in sorted() and list.sort():

python tests/functional/benchmark_sorting.py

Development

# Create and activate virtual environment
virtualenv --python=python3.12 .venv
source .venv/bin/activate

# Install with dev dependencies
pip install -e ".[dev]"

# Run tests
python manager.py run-tests
python manager.py run-coverage

# Lint and security scan
pylint core_algorithms
bandit -r core_algorithms

# Run across all supported Python versions
tox

Contributing

Contributions are welcome! Please:

  1. Fork the repository

  2. Create a feature branch

  3. Write tests for new functionality

  4. Ensure all tests pass: python manager.py run-tests

  5. Run linting: pylint core_algorithms

  6. Run security checks: bandit -r core_algorithms

  7. Submit a pull request

License

This project is licensed under the MIT License. See the LICENSE file for details.

Support

For questions or support, please open an issue on GitLab or contact the maintainers.

Authors

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

core_algorithms-1.2.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

core_algorithms-1.2.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file core_algorithms-1.2.0.tar.gz.

File metadata

  • Download URL: core_algorithms-1.2.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for core_algorithms-1.2.0.tar.gz
Algorithm Hash digest
SHA256 335dfc44219418b2be95c84be0cd6810e346666e24c2a5f29a034f03cd727f66
MD5 cfa6e260d67723f0e867838d68c37522
BLAKE2b-256 35401de0c5544d990cefe62ec6abbc1784df4b64aa5f80135ee63c12c604c621

See more details on using hashes here.

File details

Details for the file core_algorithms-1.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for core_algorithms-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5de884a0b6cb4e10880e46856e2e79f7dd407ab93bdb10808f9d137f9ed503c3
MD5 67f70b8b81f74dff097a69de6474d6ed
BLAKE2b-256 4df0d51a439c2f4901167bbb7043b96a73b580b8b57843be61621532f7ea15a5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page