This project/library contains common algorithms...
Project description
core-algorithms
A Python library containing common algorithm implementations, currently focused on sorting.
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:
Fork the repository
Create a feature branch
Write tests for new functionality
Ensure all tests pass: python manager.py run-tests
Run linting: pylint core_algorithms
Run security checks: bandit -r core_algorithms
Submit a pull request
License
This project is licensed under the MIT License. See the LICENSE file for details.
Links
Documentation: https://core-algorithms.readthedocs.io/en/latest/
Repository: https://gitlab.com/bytecode-solutions/core/core-algorithms
Issues: https://gitlab.com/bytecode-solutions/core/core-algorithms/-/issues
Changelog: https://gitlab.com/bytecode-solutions/core/core-algorithms/-/blob/master/CHANGELOG.md
Support
For questions or support, please open an issue on GitLab or contact the maintainers.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
335dfc44219418b2be95c84be0cd6810e346666e24c2a5f29a034f03cd727f66
|
|
| MD5 |
cfa6e260d67723f0e867838d68c37522
|
|
| BLAKE2b-256 |
35401de0c5544d990cefe62ec6abbc1784df4b64aa5f80135ee63c12c604c621
|
File details
Details for the file core_algorithms-1.2.0-py3-none-any.whl.
File metadata
- Download URL: core_algorithms-1.2.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5de884a0b6cb4e10880e46856e2e79f7dd407ab93bdb10808f9d137f9ed503c3
|
|
| MD5 |
67f70b8b81f74dff097a69de6474d6ed
|
|
| BLAKE2b-256 |
4df0d51a439c2f4901167bbb7043b96a73b580b8b57843be61621532f7ea15a5
|