core-algorithms 1.1.0__tar.gz → 1.2.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. core_algorithms-1.2.1/PKG-INFO +192 -0
  2. core_algorithms-1.2.1/README.rst +157 -0
  3. core_algorithms-1.2.1/core_algorithms/__init__.py +14 -0
  4. core_algorithms-1.2.1/core_algorithms/sorting/__init__.py +15 -0
  5. {core_algorithms-1.1.0 → core_algorithms-1.2.1}/core_algorithms/sorting/bubble_sort.py +6 -3
  6. core_algorithms-1.2.1/core_algorithms/sorting/insertion_sort.py +17 -0
  7. {core_algorithms-1.1.0 → core_algorithms-1.2.1}/core_algorithms/sorting/merge_sort.py +12 -9
  8. core_algorithms-1.2.1/core_algorithms/sorting/quick_sort.py +33 -0
  9. {core_algorithms-1.1.0 → core_algorithms-1.2.1}/core_algorithms/sorting/selection_sort.py +7 -4
  10. core_algorithms-1.2.1/core_algorithms.egg-info/PKG-INFO +192 -0
  11. {core_algorithms-1.1.0 → core_algorithms-1.2.1}/core_algorithms.egg-info/SOURCES.txt +2 -1
  12. core_algorithms-1.2.1/core_algorithms.egg-info/requires.txt +5 -0
  13. {core_algorithms-1.1.0 → core_algorithms-1.2.1}/pyproject.toml +19 -11
  14. {core_algorithms-1.1.0 → core_algorithms-1.2.1}/setup.py +0 -3
  15. core_algorithms-1.1.0/PKG-INFO +0 -62
  16. core_algorithms-1.1.0/README.md +0 -33
  17. core_algorithms-1.1.0/core_algorithms/sorting/__init__.py +0 -0
  18. core_algorithms-1.1.0/core_algorithms/sorting/insertion_sort.py +0 -15
  19. core_algorithms-1.1.0/core_algorithms/sorting/quick_sort.py +0 -30
  20. core_algorithms-1.1.0/core_algorithms.egg-info/PKG-INFO +0 -62
  21. core_algorithms-1.1.0/core_algorithms.egg-info/requires.txt +0 -1
  22. {core_algorithms-1.1.0 → core_algorithms-1.2.1}/LICENSE +0 -0
  23. /core_algorithms-1.1.0/core_algorithms/__init__.py → /core_algorithms-1.2.1/core_algorithms/py.typed +0 -0
  24. {core_algorithms-1.1.0 → core_algorithms-1.2.1}/core_algorithms.egg-info/dependency_links.txt +0 -0
  25. {core_algorithms-1.1.0 → core_algorithms-1.2.1}/core_algorithms.egg-info/top_level.txt +0 -0
  26. {core_algorithms-1.1.0 → core_algorithms-1.2.1}/setup.cfg +0 -0
@@ -0,0 +1,192 @@
1
+ Metadata-Version: 2.4
2
+ Name: core-algorithms
3
+ Version: 1.2.1
4
+ Summary: This project/library contains common algorithms...
5
+ Author-email: Alejandro Cora González <alek.cora.glez@gmail.com>
6
+ Maintainer: Alejandro Cora González
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://gitlab.com/bytecode-solutions/core/core-algorithms
9
+ Project-URL: Repository, https://gitlab.com/bytecode-solutions/core/core-algorithms
10
+ Project-URL: Documentation, https://core-algorithms.readthedocs.io/en/latest/
11
+ Project-URL: Issues, https://gitlab.com/bytecode-solutions/core/core-algorithms/-/issues
12
+ Project-URL: Changelog, https://gitlab.com/bytecode-solutions/core/core-algorithms/-/blob/master/CHANGELOG.md
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: Topic :: Utilities
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Programming Language :: Python :: 3.14
26
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
27
+ Requires-Python: >=3.9
28
+ Description-Content-Type: text/x-rst
29
+ License-File: LICENSE
30
+ Requires-Dist: core-tests>=2.3.0
31
+ Provides-Extra: dev
32
+ Requires-Dist: core-dev-tools>=2.1.0; extra == "dev"
33
+ Requires-Dist: core-tests>=2.3.0; extra == "dev"
34
+ Dynamic: license-file
35
+
36
+ core-algorithms
37
+ ===============================================================================
38
+
39
+ A Python library containing common algorithm implementations, currently
40
+ focused on sorting.
41
+
42
+ ===============================================================================
43
+
44
+ .. image:: https://static.pepy.tech/personalized-badge/core-algorithms?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads
45
+ :target: https://pepy.tech/projects/core-algorithms
46
+ :alt: PyPI Downloads
47
+
48
+ .. image:: https://img.shields.io/pypi/pyversions/core-algorithms.svg
49
+ :target: https://pypi.org/project/core-algorithms/
50
+ :alt: Python Versions
51
+
52
+ .. image:: https://img.shields.io/badge/license-MIT-blue.svg
53
+ :target: https://gitlab.com/bytecode-solutions/core/core-algorithms/-/blob/main/LICENSE
54
+ :alt: License
55
+
56
+ .. image:: https://gitlab.com/bytecode-solutions/core/core-algorithms/badges/release/pipeline.svg
57
+ :target: https://gitlab.com/bytecode-solutions/core/core-algorithms/-/pipelines
58
+ :alt: Pipeline Status
59
+
60
+ .. image:: https://readthedocs.org/projects/core-algorithms/badge/?version=latest
61
+ :target: https://readthedocs.org/projects/core-algorithms/
62
+ :alt: Docs Status
63
+
64
+ .. image:: https://img.shields.io/badge/security-bandit-yellow.svg
65
+ :target: https://github.com/PyCQA/bandit
66
+ :alt: Security
67
+
68
+ |
69
+
70
+
71
+ Installation
72
+ ===============================================================================
73
+
74
+ .. code-block:: bash
75
+
76
+ pip install core-algorithms
77
+ uv pip install core-algorithms
78
+
79
+
80
+ Features
81
+ ===============================================================================
82
+
83
+ * **Sorting algorithms**: bubble sort, insertion sort, merge sort, quick sort, and selection sort
84
+ * **Fully typed**: complete type annotations with ``py.typed`` marker for PEP 561 compliance
85
+ * **Broad Python support**: compatible with Python 3.9 through 3.14 and PyPy
86
+
87
+
88
+ Quick Start
89
+ ===============================================================================
90
+
91
+ .. code-block:: bash
92
+
93
+ pip install core-algorithms
94
+ pip install -e ".[dev]" # For development
95
+
96
+
97
+ Sorting
98
+ -------------------------------------------------------------------------------
99
+
100
+ Import and use any of the available sorting algorithms directly:
101
+
102
+ .. code-block:: python
103
+
104
+ from core_algorithms.sorting import bubble_sort, insertion_sort
105
+ from core_algorithms.sorting import merge_sort, quick_sort, selection_sort
106
+
107
+ data = [5, 3, 8, 1, 9, 2]
108
+
109
+ print(bubble_sort(data[:])) # [1, 2, 3, 5, 8, 9]
110
+ print(insertion_sort(data[:])) # [1, 2, 3, 5, 8, 9]
111
+ print(merge_sort(data[:])) # [1, 2, 3, 5, 8, 9]
112
+ print(selection_sort(data[:])) # [1, 2, 3, 5, 8, 9]
113
+
114
+ quick_sort(data)
115
+ print(data) # [1, 2, 3, 5, 8, 9]
116
+
117
+
118
+ Benchmark
119
+ -------------------------------------------------------------------------------
120
+
121
+ Run the sorting benchmark to compare all implementations against Python's
122
+ built-in ``sorted()`` and ``list.sort()``:
123
+
124
+ .. code-block:: bash
125
+
126
+ python tests/functional/benchmark_sorting.py
127
+
128
+
129
+ Development
130
+ ===============================================================================
131
+
132
+ .. code-block:: bash
133
+
134
+ # Create and activate virtual environment
135
+ virtualenv --python=python3.12 .venv
136
+ source .venv/bin/activate
137
+
138
+ # Install with dev dependencies
139
+ pip install -e ".[dev]"
140
+
141
+ # Run tests
142
+ python manager.py run-tests
143
+ python manager.py run-coverage
144
+
145
+ # Lint and security scan
146
+ pylint core_algorithms
147
+ bandit -r core_algorithms
148
+
149
+ # Run across all supported Python versions
150
+ tox
151
+
152
+
153
+ Contributing
154
+ ===============================================================================
155
+
156
+ Contributions are welcome! Please:
157
+
158
+ 1. Fork the repository
159
+ 2. Create a feature branch
160
+ 3. Write tests for new functionality
161
+ 4. Ensure all tests pass: ``python manager.py run-tests``
162
+ 5. Run linting: ``pylint core_algorithms``
163
+ 6. Run security checks: ``bandit -r core_algorithms``
164
+ 7. Submit a pull request
165
+
166
+
167
+ License
168
+ ===============================================================================
169
+
170
+ This project is licensed under the MIT License. See the LICENSE file for details.
171
+
172
+
173
+ Links
174
+ ===============================================================================
175
+
176
+ * **Documentation:** https://core-algorithms.readthedocs.io/en/latest/
177
+ * **Repository:** https://gitlab.com/bytecode-solutions/core/core-algorithms
178
+ * **Issues:** https://gitlab.com/bytecode-solutions/core/core-algorithms/-/issues
179
+ * **Changelog:** https://gitlab.com/bytecode-solutions/core/core-algorithms/-/blob/master/CHANGELOG.md
180
+ * **PyPI:** https://pypi.org/project/core-algorithms/
181
+
182
+
183
+ Support
184
+ ===============================================================================
185
+
186
+ For questions or support, please open an issue on GitLab or contact the maintainers.
187
+
188
+
189
+ Authors
190
+ ===============================================================================
191
+
192
+ * **Alejandro Cora González** - *Initial work* - alek.cora.glez@gmail.com
@@ -0,0 +1,157 @@
1
+ core-algorithms
2
+ ===============================================================================
3
+
4
+ A Python library containing common algorithm implementations, currently
5
+ focused on sorting.
6
+
7
+ ===============================================================================
8
+
9
+ .. image:: https://static.pepy.tech/personalized-badge/core-algorithms?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads
10
+ :target: https://pepy.tech/projects/core-algorithms
11
+ :alt: PyPI Downloads
12
+
13
+ .. image:: https://img.shields.io/pypi/pyversions/core-algorithms.svg
14
+ :target: https://pypi.org/project/core-algorithms/
15
+ :alt: Python Versions
16
+
17
+ .. image:: https://img.shields.io/badge/license-MIT-blue.svg
18
+ :target: https://gitlab.com/bytecode-solutions/core/core-algorithms/-/blob/main/LICENSE
19
+ :alt: License
20
+
21
+ .. image:: https://gitlab.com/bytecode-solutions/core/core-algorithms/badges/release/pipeline.svg
22
+ :target: https://gitlab.com/bytecode-solutions/core/core-algorithms/-/pipelines
23
+ :alt: Pipeline Status
24
+
25
+ .. image:: https://readthedocs.org/projects/core-algorithms/badge/?version=latest
26
+ :target: https://readthedocs.org/projects/core-algorithms/
27
+ :alt: Docs Status
28
+
29
+ .. image:: https://img.shields.io/badge/security-bandit-yellow.svg
30
+ :target: https://github.com/PyCQA/bandit
31
+ :alt: Security
32
+
33
+ |
34
+
35
+
36
+ Installation
37
+ ===============================================================================
38
+
39
+ .. code-block:: bash
40
+
41
+ pip install core-algorithms
42
+ uv pip install core-algorithms
43
+
44
+
45
+ Features
46
+ ===============================================================================
47
+
48
+ * **Sorting algorithms**: bubble sort, insertion sort, merge sort, quick sort, and selection sort
49
+ * **Fully typed**: complete type annotations with ``py.typed`` marker for PEP 561 compliance
50
+ * **Broad Python support**: compatible with Python 3.9 through 3.14 and PyPy
51
+
52
+
53
+ Quick Start
54
+ ===============================================================================
55
+
56
+ .. code-block:: bash
57
+
58
+ pip install core-algorithms
59
+ pip install -e ".[dev]" # For development
60
+
61
+
62
+ Sorting
63
+ -------------------------------------------------------------------------------
64
+
65
+ Import and use any of the available sorting algorithms directly:
66
+
67
+ .. code-block:: python
68
+
69
+ from core_algorithms.sorting import bubble_sort, insertion_sort
70
+ from core_algorithms.sorting import merge_sort, quick_sort, selection_sort
71
+
72
+ data = [5, 3, 8, 1, 9, 2]
73
+
74
+ print(bubble_sort(data[:])) # [1, 2, 3, 5, 8, 9]
75
+ print(insertion_sort(data[:])) # [1, 2, 3, 5, 8, 9]
76
+ print(merge_sort(data[:])) # [1, 2, 3, 5, 8, 9]
77
+ print(selection_sort(data[:])) # [1, 2, 3, 5, 8, 9]
78
+
79
+ quick_sort(data)
80
+ print(data) # [1, 2, 3, 5, 8, 9]
81
+
82
+
83
+ Benchmark
84
+ -------------------------------------------------------------------------------
85
+
86
+ Run the sorting benchmark to compare all implementations against Python's
87
+ built-in ``sorted()`` and ``list.sort()``:
88
+
89
+ .. code-block:: bash
90
+
91
+ python tests/functional/benchmark_sorting.py
92
+
93
+
94
+ Development
95
+ ===============================================================================
96
+
97
+ .. code-block:: bash
98
+
99
+ # Create and activate virtual environment
100
+ virtualenv --python=python3.12 .venv
101
+ source .venv/bin/activate
102
+
103
+ # Install with dev dependencies
104
+ pip install -e ".[dev]"
105
+
106
+ # Run tests
107
+ python manager.py run-tests
108
+ python manager.py run-coverage
109
+
110
+ # Lint and security scan
111
+ pylint core_algorithms
112
+ bandit -r core_algorithms
113
+
114
+ # Run across all supported Python versions
115
+ tox
116
+
117
+
118
+ Contributing
119
+ ===============================================================================
120
+
121
+ Contributions are welcome! Please:
122
+
123
+ 1. Fork the repository
124
+ 2. Create a feature branch
125
+ 3. Write tests for new functionality
126
+ 4. Ensure all tests pass: ``python manager.py run-tests``
127
+ 5. Run linting: ``pylint core_algorithms``
128
+ 6. Run security checks: ``bandit -r core_algorithms``
129
+ 7. Submit a pull request
130
+
131
+
132
+ License
133
+ ===============================================================================
134
+
135
+ This project is licensed under the MIT License. See the LICENSE file for details.
136
+
137
+
138
+ Links
139
+ ===============================================================================
140
+
141
+ * **Documentation:** https://core-algorithms.readthedocs.io/en/latest/
142
+ * **Repository:** https://gitlab.com/bytecode-solutions/core/core-algorithms
143
+ * **Issues:** https://gitlab.com/bytecode-solutions/core/core-algorithms/-/issues
144
+ * **Changelog:** https://gitlab.com/bytecode-solutions/core/core-algorithms/-/blob/master/CHANGELOG.md
145
+ * **PyPI:** https://pypi.org/project/core-algorithms/
146
+
147
+
148
+ Support
149
+ ===============================================================================
150
+
151
+ For questions or support, please open an issue on GitLab or contact the maintainers.
152
+
153
+
154
+ Authors
155
+ ===============================================================================
156
+
157
+ * **Alejandro Cora González** - *Initial work* - alek.cora.glez@gmail.com
@@ -0,0 +1,14 @@
1
+ """Common algorithm implementations."""
2
+
3
+ from importlib.metadata import PackageNotFoundError, version
4
+
5
+ try:
6
+ __version__ = version("core-algorithms")
7
+
8
+ except PackageNotFoundError:
9
+ __version__ = "unknown"
10
+
11
+
12
+ __all__ = [
13
+ "__version__",
14
+ ]
@@ -0,0 +1,15 @@
1
+ """Sorting algorithm implementations."""
2
+
3
+ from .bubble_sort import bubble_sort
4
+ from .insertion_sort import insertion_sort
5
+ from .merge_sort import merge_sort
6
+ from .quick_sort import quick_sort
7
+ from .selection_sort import selection_sort
8
+
9
+ __all__ = [
10
+ "bubble_sort",
11
+ "insertion_sort",
12
+ "merge_sort",
13
+ "quick_sort",
14
+ "selection_sort",
15
+ ]
@@ -1,9 +1,12 @@
1
- # -*- coding: utf-8 -*-
1
+ """Bubble sort algorithm implementation."""
2
2
 
3
- from typing import List
4
3
 
4
+ def bubble_sort(array: list):
5
+ """
6
+ Sort *array* in ascending order using bubble
7
+ sort and return it.
8
+ """
5
9
 
6
- def bubble_sort(array: List):
7
10
  def swap(x: int, y: int):
8
11
  array[x], array[y] = array[y], array[x]
9
12
 
@@ -0,0 +1,17 @@
1
+ """Insertion sort algorithm implementation."""
2
+
3
+
4
+ def insertion_sort(array: list):
5
+ """
6
+ Sort *array* in ascending order using insertion
7
+ sort and return it."""
8
+
9
+ for i, cursor in enumerate(array):
10
+ pos = i
11
+ while pos > 0 and array[pos - 1] > cursor:
12
+ array[pos] = array[pos - 1]
13
+ pos = pos - 1
14
+
15
+ array[pos] = cursor
16
+
17
+ return array
@@ -1,9 +1,11 @@
1
- # -*- coding: utf-8 -*-
1
+ """Merge sort algorithm implementation."""
2
2
 
3
- from typing import List
4
3
 
4
+ def merge_sort(array: list):
5
+ """
6
+ Sort *array* in ascending order using merge
7
+ sort and return it."""
5
8
 
6
- def merge_sort(array: List):
7
9
  # The last array split...
8
10
  if len(array) <= 1:
9
11
  return array
@@ -13,10 +15,10 @@ def merge_sort(array: List):
13
15
  left, right = merge_sort(array[:mid]), merge_sort(array[mid:])
14
16
 
15
17
  # Merge each side together...
16
- return merge(left, right, array.copy())
18
+ return _merge(left, right, array.copy())
17
19
 
18
20
 
19
- def merge(left, right, merged):
21
+ def _merge(left, right, merged):
20
22
  left_cursor, right_cursor = 0, 0
21
23
 
22
24
  while left_cursor < len(left) and right_cursor < len(right):
@@ -29,10 +31,11 @@ def merge(left, right, merged):
29
31
  merged[left_cursor + right_cursor] = right[right_cursor]
30
32
  right_cursor += 1
31
33
 
32
- for left_cursor in range(left_cursor, len(left)):
33
- merged[left_cursor + right_cursor] = left[left_cursor]
34
+ # Copy whatever remains on either side...
35
+ for i in range(left_cursor, len(left)):
36
+ merged[i + right_cursor] = left[i]
34
37
 
35
- for right_cursor in range(right_cursor, len(right)):
36
- merged[left_cursor + right_cursor] = right[right_cursor]
38
+ for j in range(right_cursor, len(right)):
39
+ merged[left_cursor + j] = right[j]
37
40
 
38
41
  return merged
@@ -0,0 +1,33 @@
1
+ """Quick sort algorithm implementation."""
2
+
3
+
4
+ def _partition(array: list, begin: int, end: int):
5
+ pivot_idx = begin
6
+ for i in range(begin + 1, end + 1):
7
+ if array[i] <= array[begin]:
8
+ pivot_idx += 1
9
+ array[i], array[pivot_idx] = array[pivot_idx], array[i]
10
+
11
+ array[pivot_idx], array[begin] = array[begin], array[pivot_idx]
12
+ return pivot_idx
13
+
14
+
15
+ def _quick_sort_recursion(array: list, begin: int, end: int):
16
+ if begin >= end:
17
+ return
18
+
19
+ pivot_idx = _partition(array, begin, end)
20
+ _quick_sort_recursion(array, begin, pivot_idx - 1)
21
+ _quick_sort_recursion(array, pivot_idx + 1, end)
22
+
23
+
24
+ def quick_sort(array: list, begin=0, end=None):
25
+ """
26
+ Sort *array* in ascending order using quick
27
+ sort and return it.
28
+ """
29
+
30
+ if not end:
31
+ end = len(array) - 1
32
+
33
+ return _quick_sort_recursion(array, begin, end)
@@ -1,10 +1,13 @@
1
- # -*- coding: utf-8 -*-
1
+ """Selection sort algorithm implementation."""
2
2
 
3
- from typing import List
4
3
 
4
+ def selection_sort(array: list):
5
+ """
6
+ Sort *array* in ascending order using selection
7
+ sort and return it.
8
+ """
5
9
 
6
- def selection_sort(array: List):
7
- for i in range(len(array)):
10
+ for i, _ in enumerate(array):
8
11
  minimum = i
9
12
  for j in range(i + 1, len(array)):
10
13
  # Select the smallest value...
@@ -0,0 +1,192 @@
1
+ Metadata-Version: 2.4
2
+ Name: core-algorithms
3
+ Version: 1.2.1
4
+ Summary: This project/library contains common algorithms...
5
+ Author-email: Alejandro Cora González <alek.cora.glez@gmail.com>
6
+ Maintainer: Alejandro Cora González
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://gitlab.com/bytecode-solutions/core/core-algorithms
9
+ Project-URL: Repository, https://gitlab.com/bytecode-solutions/core/core-algorithms
10
+ Project-URL: Documentation, https://core-algorithms.readthedocs.io/en/latest/
11
+ Project-URL: Issues, https://gitlab.com/bytecode-solutions/core/core-algorithms/-/issues
12
+ Project-URL: Changelog, https://gitlab.com/bytecode-solutions/core/core-algorithms/-/blob/master/CHANGELOG.md
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Development Status :: 5 - Production/Stable
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: Topic :: Utilities
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3 :: Only
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: 3.13
25
+ Classifier: Programming Language :: Python :: 3.14
26
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
27
+ Requires-Python: >=3.9
28
+ Description-Content-Type: text/x-rst
29
+ License-File: LICENSE
30
+ Requires-Dist: core-tests>=2.3.0
31
+ Provides-Extra: dev
32
+ Requires-Dist: core-dev-tools>=2.1.0; extra == "dev"
33
+ Requires-Dist: core-tests>=2.3.0; extra == "dev"
34
+ Dynamic: license-file
35
+
36
+ core-algorithms
37
+ ===============================================================================
38
+
39
+ A Python library containing common algorithm implementations, currently
40
+ focused on sorting.
41
+
42
+ ===============================================================================
43
+
44
+ .. image:: https://static.pepy.tech/personalized-badge/core-algorithms?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads
45
+ :target: https://pepy.tech/projects/core-algorithms
46
+ :alt: PyPI Downloads
47
+
48
+ .. image:: https://img.shields.io/pypi/pyversions/core-algorithms.svg
49
+ :target: https://pypi.org/project/core-algorithms/
50
+ :alt: Python Versions
51
+
52
+ .. image:: https://img.shields.io/badge/license-MIT-blue.svg
53
+ :target: https://gitlab.com/bytecode-solutions/core/core-algorithms/-/blob/main/LICENSE
54
+ :alt: License
55
+
56
+ .. image:: https://gitlab.com/bytecode-solutions/core/core-algorithms/badges/release/pipeline.svg
57
+ :target: https://gitlab.com/bytecode-solutions/core/core-algorithms/-/pipelines
58
+ :alt: Pipeline Status
59
+
60
+ .. image:: https://readthedocs.org/projects/core-algorithms/badge/?version=latest
61
+ :target: https://readthedocs.org/projects/core-algorithms/
62
+ :alt: Docs Status
63
+
64
+ .. image:: https://img.shields.io/badge/security-bandit-yellow.svg
65
+ :target: https://github.com/PyCQA/bandit
66
+ :alt: Security
67
+
68
+ |
69
+
70
+
71
+ Installation
72
+ ===============================================================================
73
+
74
+ .. code-block:: bash
75
+
76
+ pip install core-algorithms
77
+ uv pip install core-algorithms
78
+
79
+
80
+ Features
81
+ ===============================================================================
82
+
83
+ * **Sorting algorithms**: bubble sort, insertion sort, merge sort, quick sort, and selection sort
84
+ * **Fully typed**: complete type annotations with ``py.typed`` marker for PEP 561 compliance
85
+ * **Broad Python support**: compatible with Python 3.9 through 3.14 and PyPy
86
+
87
+
88
+ Quick Start
89
+ ===============================================================================
90
+
91
+ .. code-block:: bash
92
+
93
+ pip install core-algorithms
94
+ pip install -e ".[dev]" # For development
95
+
96
+
97
+ Sorting
98
+ -------------------------------------------------------------------------------
99
+
100
+ Import and use any of the available sorting algorithms directly:
101
+
102
+ .. code-block:: python
103
+
104
+ from core_algorithms.sorting import bubble_sort, insertion_sort
105
+ from core_algorithms.sorting import merge_sort, quick_sort, selection_sort
106
+
107
+ data = [5, 3, 8, 1, 9, 2]
108
+
109
+ print(bubble_sort(data[:])) # [1, 2, 3, 5, 8, 9]
110
+ print(insertion_sort(data[:])) # [1, 2, 3, 5, 8, 9]
111
+ print(merge_sort(data[:])) # [1, 2, 3, 5, 8, 9]
112
+ print(selection_sort(data[:])) # [1, 2, 3, 5, 8, 9]
113
+
114
+ quick_sort(data)
115
+ print(data) # [1, 2, 3, 5, 8, 9]
116
+
117
+
118
+ Benchmark
119
+ -------------------------------------------------------------------------------
120
+
121
+ Run the sorting benchmark to compare all implementations against Python's
122
+ built-in ``sorted()`` and ``list.sort()``:
123
+
124
+ .. code-block:: bash
125
+
126
+ python tests/functional/benchmark_sorting.py
127
+
128
+
129
+ Development
130
+ ===============================================================================
131
+
132
+ .. code-block:: bash
133
+
134
+ # Create and activate virtual environment
135
+ virtualenv --python=python3.12 .venv
136
+ source .venv/bin/activate
137
+
138
+ # Install with dev dependencies
139
+ pip install -e ".[dev]"
140
+
141
+ # Run tests
142
+ python manager.py run-tests
143
+ python manager.py run-coverage
144
+
145
+ # Lint and security scan
146
+ pylint core_algorithms
147
+ bandit -r core_algorithms
148
+
149
+ # Run across all supported Python versions
150
+ tox
151
+
152
+
153
+ Contributing
154
+ ===============================================================================
155
+
156
+ Contributions are welcome! Please:
157
+
158
+ 1. Fork the repository
159
+ 2. Create a feature branch
160
+ 3. Write tests for new functionality
161
+ 4. Ensure all tests pass: ``python manager.py run-tests``
162
+ 5. Run linting: ``pylint core_algorithms``
163
+ 6. Run security checks: ``bandit -r core_algorithms``
164
+ 7. Submit a pull request
165
+
166
+
167
+ License
168
+ ===============================================================================
169
+
170
+ This project is licensed under the MIT License. See the LICENSE file for details.
171
+
172
+
173
+ Links
174
+ ===============================================================================
175
+
176
+ * **Documentation:** https://core-algorithms.readthedocs.io/en/latest/
177
+ * **Repository:** https://gitlab.com/bytecode-solutions/core/core-algorithms
178
+ * **Issues:** https://gitlab.com/bytecode-solutions/core/core-algorithms/-/issues
179
+ * **Changelog:** https://gitlab.com/bytecode-solutions/core/core-algorithms/-/blob/master/CHANGELOG.md
180
+ * **PyPI:** https://pypi.org/project/core-algorithms/
181
+
182
+
183
+ Support
184
+ ===============================================================================
185
+
186
+ For questions or support, please open an issue on GitLab or contact the maintainers.
187
+
188
+
189
+ Authors
190
+ ===============================================================================
191
+
192
+ * **Alejandro Cora González** - *Initial work* - alek.cora.glez@gmail.com
@@ -1,8 +1,9 @@
1
1
  LICENSE
2
- README.md
2
+ README.rst
3
3
  pyproject.toml
4
4
  setup.py
5
5
  core_algorithms/__init__.py
6
+ core_algorithms/py.typed
6
7
  core_algorithms.egg-info/PKG-INFO
7
8
  core_algorithms.egg-info/SOURCES.txt
8
9
  core_algorithms.egg-info/dependency_links.txt
@@ -0,0 +1,5 @@
1
+ core-tests>=2.3.0
2
+
3
+ [dev]
4
+ core-dev-tools>=2.1.0
5
+ core-tests>=2.3.0
@@ -9,7 +9,7 @@ build-backend = "setuptools.build_meta"
9
9
  [project]
10
10
  name = "core-algorithms"
11
11
  description = "This project/library contains common algorithms..."
12
- version = "1.1.0"
12
+ version = "1.2.1"
13
13
 
14
14
  authors = [
15
15
  {name = "Alejandro Cora González", email = "alek.cora.glez@gmail.com"}
@@ -19,36 +19,44 @@ maintainers = [
19
19
  {name = "Alejandro Cora González"}
20
20
  ]
21
21
 
22
- requires-python = ">=3.7"
23
- license = {text = "MIT"}
24
- readme = "README.md"
22
+ requires-python = ">=3.9"
23
+ license = "MIT"
24
+ readme = "README.rst"
25
25
 
26
26
  classifiers = [
27
27
  # Classifiers -> https://pypi.org/classifiers/
28
- "License :: OSI Approved :: MIT License",
29
28
  "Intended Audience :: Developers",
30
29
  "Development Status :: 5 - Production/Stable",
31
30
  "Topic :: Software Development :: Libraries :: Python Modules",
32
31
  "Topic :: Utilities",
32
+ "Programming Language :: Python",
33
33
  "Programming Language :: Python :: 3",
34
- "Programming Language :: Python :: 3.7",
35
- "Programming Language :: Python :: 3.8",
34
+ "Programming Language :: Python :: 3 :: Only",
36
35
  "Programming Language :: Python :: 3.9",
37
36
  "Programming Language :: Python :: 3.10",
38
37
  "Programming Language :: Python :: 3.11",
39
38
  "Programming Language :: Python :: 3.12",
40
- "Programming Language :: Python :: 3.13"
39
+ "Programming Language :: Python :: 3.13",
40
+ "Programming Language :: Python :: 3.14",
41
+ "Programming Language :: Python :: Implementation :: PyPy",
41
42
  ]
42
43
 
43
44
  dependencies = [
44
- "core-tests>=1.1.0"
45
+ "core-tests>=2.3.0"
45
46
  ]
46
47
 
47
- #[project.optional-dependencies]
48
- #test = []
48
+ [project.optional-dependencies]
49
+ dev = [
50
+ "core-dev-tools>=2.1.0",
51
+ "core-tests>=2.3.0",
52
+ ]
49
53
 
50
54
  [project.urls]
51
55
  Homepage = "https://gitlab.com/bytecode-solutions/core/core-algorithms"
52
56
  Repository = "https://gitlab.com/bytecode-solutions/core/core-algorithms"
57
+ Documentation = "https://core-algorithms.readthedocs.io/en/latest/"
53
58
  Issues = "https://gitlab.com/bytecode-solutions/core/core-algorithms/-/issues"
54
59
  Changelog = "https://gitlab.com/bytecode-solutions/core/core-algorithms/-/blob/master/CHANGELOG.md"
60
+
61
+ [tool.setuptools.package-data]
62
+ "core_algorithms" = ["py.typed"]
@@ -1,6 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
-
3
1
  from setuptools import setup
4
2
 
5
-
6
3
  setup()
@@ -1,62 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: core-algorithms
3
- Version: 1.1.0
4
- Summary: This project/library contains common algorithms...
5
- Author-email: Alejandro Cora González <alek.cora.glez@gmail.com>
6
- Maintainer: Alejandro Cora González
7
- License: MIT
8
- Project-URL: Homepage, https://gitlab.com/bytecode-solutions/core/core-algorithms
9
- Project-URL: Repository, https://gitlab.com/bytecode-solutions/core/core-algorithms
10
- Project-URL: Issues, https://gitlab.com/bytecode-solutions/core/core-algorithms/-/issues
11
- Project-URL: Changelog, https://gitlab.com/bytecode-solutions/core/core-algorithms/-/blob/master/CHANGELOG.md
12
- Classifier: License :: OSI Approved :: MIT License
13
- Classifier: Intended Audience :: Developers
14
- Classifier: Development Status :: 5 - Production/Stable
15
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
- Classifier: Topic :: Utilities
17
- Classifier: Programming Language :: Python :: 3
18
- Classifier: Programming Language :: Python :: 3.7
19
- Classifier: Programming Language :: Python :: 3.8
20
- Classifier: Programming Language :: Python :: 3.9
21
- Classifier: Programming Language :: Python :: 3.10
22
- Classifier: Programming Language :: Python :: 3.11
23
- Classifier: Programming Language :: Python :: 3.12
24
- Classifier: Programming Language :: Python :: 3.13
25
- Requires-Python: >=3.7
26
- Description-Content-Type: text/markdown
27
- License-File: LICENSE
28
- Requires-Dist: core-tests>=1.1.0
29
-
30
- # core-algorithms
31
- _______________________________________________________________________________
32
-
33
- This project/library contains common algorithms...
34
-
35
- ## Execution Environment
36
-
37
- ### Install libraries
38
- ```commandline
39
- pip install --upgrade pip
40
- pip install virtualenv
41
- ```
42
-
43
- ### Create the Python Virtual Environment.
44
- ```commandline
45
- virtualenv --python=python3.11 .venv
46
- ```
47
-
48
- ### Activate the Virtual Environment.
49
- ```commandline
50
- source .venv/bin/activate
51
- ```
52
-
53
- ### Install required libraries.
54
- ```commandline
55
- pip install .
56
- ```
57
-
58
- ### Check tests and coverage...
59
- ```commandline
60
- python manager.py run-test
61
- python manager.py run-coverage
62
- ```
@@ -1,33 +0,0 @@
1
- # core-algorithms
2
- _______________________________________________________________________________
3
-
4
- This project/library contains common algorithms...
5
-
6
- ## Execution Environment
7
-
8
- ### Install libraries
9
- ```commandline
10
- pip install --upgrade pip
11
- pip install virtualenv
12
- ```
13
-
14
- ### Create the Python Virtual Environment.
15
- ```commandline
16
- virtualenv --python=python3.11 .venv
17
- ```
18
-
19
- ### Activate the Virtual Environment.
20
- ```commandline
21
- source .venv/bin/activate
22
- ```
23
-
24
- ### Install required libraries.
25
- ```commandline
26
- pip install .
27
- ```
28
-
29
- ### Check tests and coverage...
30
- ```commandline
31
- python manager.py run-test
32
- python manager.py run-coverage
33
- ```
File without changes
@@ -1,15 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- from typing import List
4
-
5
-
6
- def insertion_sort(array: List):
7
- for i in range(len(array)):
8
- cursor, pos = array[i], i
9
- while pos > 0 and array[pos - 1] > cursor:
10
- array[pos] = array[pos - 1]
11
- pos = pos - 1
12
-
13
- array[pos] = cursor
14
-
15
- return array
@@ -1,30 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- from typing import List
4
-
5
-
6
- def partition(array: List, begin: int, end: int):
7
- pivot_idx = begin
8
- for i in range(begin + 1, end + 1):
9
- if array[i] <= array[begin]:
10
- pivot_idx += 1
11
- array[i], array[pivot_idx] = array[pivot_idx], array[i]
12
-
13
- array[pivot_idx], array[begin] = array[begin], array[pivot_idx]
14
- return pivot_idx
15
-
16
-
17
- def quick_sort_recursion(array: List, begin: int, end: int):
18
- if begin >= end:
19
- return
20
-
21
- pivot_idx = partition(array, begin, end)
22
- quick_sort_recursion(array, begin, pivot_idx - 1)
23
- quick_sort_recursion(array, pivot_idx + 1, end)
24
-
25
-
26
- def quick_sort(array: List, begin=0, end=None):
27
- if not end:
28
- end = len(array) - 1
29
-
30
- return quick_sort_recursion(array, begin, end)
@@ -1,62 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: core-algorithms
3
- Version: 1.1.0
4
- Summary: This project/library contains common algorithms...
5
- Author-email: Alejandro Cora González <alek.cora.glez@gmail.com>
6
- Maintainer: Alejandro Cora González
7
- License: MIT
8
- Project-URL: Homepage, https://gitlab.com/bytecode-solutions/core/core-algorithms
9
- Project-URL: Repository, https://gitlab.com/bytecode-solutions/core/core-algorithms
10
- Project-URL: Issues, https://gitlab.com/bytecode-solutions/core/core-algorithms/-/issues
11
- Project-URL: Changelog, https://gitlab.com/bytecode-solutions/core/core-algorithms/-/blob/master/CHANGELOG.md
12
- Classifier: License :: OSI Approved :: MIT License
13
- Classifier: Intended Audience :: Developers
14
- Classifier: Development Status :: 5 - Production/Stable
15
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
- Classifier: Topic :: Utilities
17
- Classifier: Programming Language :: Python :: 3
18
- Classifier: Programming Language :: Python :: 3.7
19
- Classifier: Programming Language :: Python :: 3.8
20
- Classifier: Programming Language :: Python :: 3.9
21
- Classifier: Programming Language :: Python :: 3.10
22
- Classifier: Programming Language :: Python :: 3.11
23
- Classifier: Programming Language :: Python :: 3.12
24
- Classifier: Programming Language :: Python :: 3.13
25
- Requires-Python: >=3.7
26
- Description-Content-Type: text/markdown
27
- License-File: LICENSE
28
- Requires-Dist: core-tests>=1.1.0
29
-
30
- # core-algorithms
31
- _______________________________________________________________________________
32
-
33
- This project/library contains common algorithms...
34
-
35
- ## Execution Environment
36
-
37
- ### Install libraries
38
- ```commandline
39
- pip install --upgrade pip
40
- pip install virtualenv
41
- ```
42
-
43
- ### Create the Python Virtual Environment.
44
- ```commandline
45
- virtualenv --python=python3.11 .venv
46
- ```
47
-
48
- ### Activate the Virtual Environment.
49
- ```commandline
50
- source .venv/bin/activate
51
- ```
52
-
53
- ### Install required libraries.
54
- ```commandline
55
- pip install .
56
- ```
57
-
58
- ### Check tests and coverage...
59
- ```commandline
60
- python manager.py run-test
61
- python manager.py run-coverage
62
- ```
@@ -1 +0,0 @@
1
- core-tests>=1.1.0
File without changes