pyfastcdc 0.2.1__tar.gz → 0.3.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 (35) hide show
  1. {pyfastcdc-0.2.1/pyfastcdc.egg-info → pyfastcdc-0.3.1}/PKG-INFO +4 -3
  2. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/README.md +2 -2
  3. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/pyfastcdc/__init__.py +1 -1
  4. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/pyfastcdc/__init__.pyi +2 -0
  5. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/pyfastcdc/cy/fastcdc.pyx +1 -1
  6. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/pyfastcdc/py/fastcdc.py +1 -1
  7. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/pyfastcdc/utils.py +10 -0
  8. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1/pyfastcdc.egg-info}/PKG-INFO +4 -3
  9. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/pyfastcdc.egg-info/SOURCES.txt +3 -1
  10. pyfastcdc-0.3.1/pyproject.toml +8 -0
  11. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/setup.py +5 -1
  12. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/tests/test_arguments.py +1 -1
  13. pyfastcdc-0.3.1/tests/test_correctness.py +679 -0
  14. pyfastcdc-0.3.1/tests/test_threading.py +54 -0
  15. pyfastcdc-0.3.1/tests/test_utils.py +61 -0
  16. pyfastcdc-0.2.1/pyproject.toml +0 -3
  17. pyfastcdc-0.2.1/tests/test_correctness.py +0 -454
  18. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/LICENSE +0 -0
  19. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/MANIFEST.in +0 -0
  20. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/pyfastcdc/common.py +0 -0
  21. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/pyfastcdc/cy/__init__.py +0 -0
  22. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/pyfastcdc/cy/chunk.pxd +0 -0
  23. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/pyfastcdc/cy/chunk.pyx +0 -0
  24. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/pyfastcdc/cy/constants.pxd +0 -0
  25. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/pyfastcdc/cy/constants.pyx +0 -0
  26. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/pyfastcdc/py/__init__.py +0 -0
  27. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/pyfastcdc/py/chunk.py +0 -0
  28. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/pyfastcdc/py/constants.py +0 -0
  29. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/pyfastcdc/py.typed +0 -0
  30. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/pyfastcdc.egg-info/dependency_links.txt +0 -0
  31. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/pyfastcdc.egg-info/requires.txt +0 -0
  32. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/pyfastcdc.egg-info/top_level.txt +0 -0
  33. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/requirements.dev.txt +0 -0
  34. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/requirements.txt +0 -0
  35. {pyfastcdc-0.2.1 → pyfastcdc-0.3.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyfastcdc
3
- Version: 0.2.1
3
+ Version: 0.3.1
4
4
  Summary: A high-performance FastCDC 2020 implementation written in Python + Cython
5
5
  Author: Fallen_Breath
6
6
  License: MIT
@@ -15,6 +15,7 @@ Classifier: Programming Language :: Python :: 3.11
15
15
  Classifier: Programming Language :: Python :: 3.12
16
16
  Classifier: Programming Language :: Python :: 3.13
17
17
  Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Programming Language :: Python :: 3.15
18
19
  Requires-Python: >=3.6
19
20
  Description-Content-Type: text/markdown
20
21
  License-File: LICENSE
@@ -44,7 +45,7 @@ Dynamic: summary
44
45
 
45
46
  A high-performance FastCDC 2020 implementation written in Python + [Cython](https://github.com/cython/cython)
46
47
 
47
- Supports Python 3.6+. Provides prebuilt wheels for Python 3.8+
48
+ Supports Python 3.6+. Provides prebuilt wheels for Python 3.9+
48
49
 
49
50
  Its core algorithm implementation is a direct port of the v2020 module from [nlfiedler/fastcdc-rs](https://github.com/nlfiedler/fastcdc-rs),
50
51
  which means that the output of PyFastCDC completely matches the output of nlfiedler/fastcdc-rs
@@ -67,7 +68,7 @@ which is significantly slower (about 0.5% or less in memory chunking speed)
67
68
 
68
69
  <details>
69
70
 
70
- <summary>I only want to use the Cython implemetion, not the slow pure-Python one</summary>
71
+ <summary>I only want to use the Cython implementation, not the slow pure-Python one</summary>
71
72
 
72
73
  You can set the environment variable `PYFASTCDC_REQUIRE_CYTHON=true` or `PYFASTCDC_REQUIRE_CYTHON=1` for the `pip` installation command
73
74
  to disable the pure-Python fallback on extension compilation error and make the installation fail hard.
@@ -6,7 +6,7 @@
6
6
 
7
7
  A high-performance FastCDC 2020 implementation written in Python + [Cython](https://github.com/cython/cython)
8
8
 
9
- Supports Python 3.6+. Provides prebuilt wheels for Python 3.8+
9
+ Supports Python 3.6+. Provides prebuilt wheels for Python 3.9+
10
10
 
11
11
  Its core algorithm implementation is a direct port of the v2020 module from [nlfiedler/fastcdc-rs](https://github.com/nlfiedler/fastcdc-rs),
12
12
  which means that the output of PyFastCDC completely matches the output of nlfiedler/fastcdc-rs
@@ -29,7 +29,7 @@ which is significantly slower (about 0.5% or less in memory chunking speed)
29
29
 
30
30
  <details>
31
31
 
32
- <summary>I only want to use the Cython implemetion, not the slow pure-Python one</summary>
32
+ <summary>I only want to use the Cython implementation, not the slow pure-Python one</summary>
33
33
 
34
34
  You can set the environment variable `PYFASTCDC_REQUIRE_CYTHON=true` or `PYFASTCDC_REQUIRE_CYTHON=1` for the `pip` installation command
35
35
  to disable the pure-Python fallback on extension compilation error and make the installation fail hard.
@@ -1,4 +1,4 @@
1
- __version__ = '0.2.1'
1
+ __version__ = '0.3.1'
2
2
 
3
3
  __all__ = [
4
4
  'BinaryStreamReader',
@@ -30,6 +30,8 @@ class FastCDC:
30
30
  """
31
31
  The FastCDC 2020 chunker implementation
32
32
 
33
+ The object is not concurrent-proof, avoid using it concurrently
34
+
33
35
  Paper: https://ieeexplore.ieee.org/document/9055082
34
36
  """
35
37
 
@@ -66,7 +66,7 @@ cdef class FastCDC:
66
66
  self.config.min_size = min_size
67
67
  self.config.max_size = max_size
68
68
 
69
- bits = avg_size.bit_length() - 1
69
+ bits = utils.logarithm2(avg_size)
70
70
  self.config.mask_s = MASKS[bits + normalized_chunking]
71
71
  self.config.mask_l = MASKS[bits - normalized_chunking]
72
72
  self.config.mask_s_ls = self.config.mask_s << 1
@@ -81,7 +81,7 @@ class FastCDC:
81
81
  if not (0 <= normalized_chunking <= 3):
82
82
  raise ValueError(f'normalized_chunking {normalized_chunking} is out of range [0, 3]')
83
83
 
84
- bits = avg_size.bit_length() - 1
84
+ bits = utils.logarithm2(avg_size)
85
85
  mask_s = MASKS[bits + normalized_chunking]
86
86
  mask_l = MASKS[bits - normalized_chunking]
87
87
  mask_s_ls = (mask_s << 1) & _UINT64_MASK
@@ -1,3 +1,4 @@
1
+ import math
1
2
  import mmap
2
3
  import os
3
4
  from pathlib import Path
@@ -8,6 +9,15 @@ from pyfastcdc.common import BinaryStreamReader
8
9
  ReadintoFunc = Callable[[memoryview], int]
9
10
 
10
11
 
12
+ def logarithm2(value: int) -> int:
13
+ # The same as the nlfiedler/fastcdc-rs v4.0.1 Rust implementation: (value as f64).log2().round() as u32
14
+ if value < 0:
15
+ raise ValueError(f'value must be non-negative, got {value}')
16
+ if value == 0:
17
+ return 0
18
+ return math.floor(math.log2(value) + 0.5)
19
+
20
+
11
21
  def create_memoryview_from_buffer(buf: Union[bytes, bytearray, memoryview]) -> memoryview:
12
22
  if isinstance(buf, (bytes, bytearray, memoryview)):
13
23
  return memoryview(buf)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyfastcdc
3
- Version: 0.2.1
3
+ Version: 0.3.1
4
4
  Summary: A high-performance FastCDC 2020 implementation written in Python + Cython
5
5
  Author: Fallen_Breath
6
6
  License: MIT
@@ -15,6 +15,7 @@ Classifier: Programming Language :: Python :: 3.11
15
15
  Classifier: Programming Language :: Python :: 3.12
16
16
  Classifier: Programming Language :: Python :: 3.13
17
17
  Classifier: Programming Language :: Python :: 3.14
18
+ Classifier: Programming Language :: Python :: 3.15
18
19
  Requires-Python: >=3.6
19
20
  Description-Content-Type: text/markdown
20
21
  License-File: LICENSE
@@ -44,7 +45,7 @@ Dynamic: summary
44
45
 
45
46
  A high-performance FastCDC 2020 implementation written in Python + [Cython](https://github.com/cython/cython)
46
47
 
47
- Supports Python 3.6+. Provides prebuilt wheels for Python 3.8+
48
+ Supports Python 3.6+. Provides prebuilt wheels for Python 3.9+
48
49
 
49
50
  Its core algorithm implementation is a direct port of the v2020 module from [nlfiedler/fastcdc-rs](https://github.com/nlfiedler/fastcdc-rs),
50
51
  which means that the output of PyFastCDC completely matches the output of nlfiedler/fastcdc-rs
@@ -67,7 +68,7 @@ which is significantly slower (about 0.5% or less in memory chunking speed)
67
68
 
68
69
  <details>
69
70
 
70
- <summary>I only want to use the Cython implemetion, not the slow pure-Python one</summary>
71
+ <summary>I only want to use the Cython implementation, not the slow pure-Python one</summary>
71
72
 
72
73
  You can set the environment variable `PYFASTCDC_REQUIRE_CYTHON=true` or `PYFASTCDC_REQUIRE_CYTHON=1` for the `pip` installation command
73
74
  to disable the pure-Python fallback on extension compilation error and make the installation fail hard.
@@ -26,4 +26,6 @@ pyfastcdc/py/chunk.py
26
26
  pyfastcdc/py/constants.py
27
27
  pyfastcdc/py/fastcdc.py
28
28
  tests/test_arguments.py
29
- tests/test_correctness.py
29
+ tests/test_correctness.py
30
+ tests/test_threading.py
31
+ tests/test_utils.py
@@ -0,0 +1,8 @@
1
+ [build-system]
2
+ requires = [
3
+ "setuptools; python_version < '3.13'",
4
+ "setuptools>=75.7; python_version >= '3.13'",
5
+ "Cython>=3; python_version < '3.13'",
6
+ "Cython>=3.3; python_version >= '3.13'",
7
+ ]
8
+ build-backend = "setuptools.build_meta"
@@ -92,7 +92,10 @@ else:
92
92
  from Cython.Build import cythonize
93
93
  ext_modules = cythonize(
94
94
  'pyfastcdc/cy/*.pyx',
95
- compiler_directives={'language_level': '3'},
95
+ compiler_directives={
96
+ 'language_level': '3',
97
+ **({'freethreading_compatible': True} if sys.version_info >= (3, 13) else {}),
98
+ },
96
99
  )
97
100
 
98
101
  print(f'setuptools_version: {setuptools_version}')
@@ -135,6 +138,7 @@ setup(
135
138
  'Programming Language :: Python :: 3.12',
136
139
  'Programming Language :: Python :: 3.13',
137
140
  'Programming Language :: Python :: 3.14',
141
+ 'Programming Language :: Python :: 3.15',
138
142
  ],
139
143
  ext_modules=ext_modules,
140
144
  cmdclass={'build_ext': BuildExt},
@@ -102,4 +102,4 @@ class TestAvgSize:
102
102
 
103
103
  # larger avg_size means fewer chunks
104
104
  for i in range(1, len(chunk_counts)):
105
- assert chunk_counts[i] <= chunk_counts[i - 1]
105
+ assert chunk_counts[i] <= chunk_counts[i - 1]