cbits 0.1.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.
- cbits-0.1.1/.clang-format +141 -0
- cbits-0.1.1/.github/workflows/build_and_publish.yml +95 -0
- cbits-0.1.1/.github/workflows/deploy_doxygen.yml +35 -0
- cbits-0.1.1/.gitignore +44 -0
- cbits-0.1.1/CHANGELOG.md +14 -0
- cbits-0.1.1/CMakeLists.txt +86 -0
- cbits-0.1.1/Doxyfile +2581 -0
- cbits-0.1.1/LICENSE +201 -0
- cbits-0.1.1/PKG-INFO +131 -0
- cbits-0.1.1/README.md +107 -0
- cbits-0.1.1/include/bitvector.h +191 -0
- cbits-0.1.1/include/compat.h +306 -0
- cbits-0.1.1/pyproject.toml +40 -0
- cbits-0.1.1/python/binding.c +950 -0
- cbits-0.1.1/python/cbits/__init__.py +53 -0
- cbits-0.1.1/src/bitvector.c +191 -0
- cbits-0.1.1/src/compat_dispatch.c +99 -0
- cbits-0.1.1/tests/test_contains.py +57 -0
- cbits-0.1.1/tests/test_core.py +233 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
# .clang-format for PEP 7 (Python C Style Guide)
|
|
2
|
+
# See: https://peps.python.org/pep-0007/
|
|
3
|
+
---
|
|
4
|
+
BasedOnStyle: Google
|
|
5
|
+
Language: C
|
|
6
|
+
|
|
7
|
+
# Indentation and whitespace
|
|
8
|
+
IndentWidth: 4
|
|
9
|
+
TabWidth: 4
|
|
10
|
+
UseTab: Never
|
|
11
|
+
ColumnLimit: 79
|
|
12
|
+
ContinuationIndentWidth: 4
|
|
13
|
+
IndentCaseLabels: true
|
|
14
|
+
IndentGotoLabels: false
|
|
15
|
+
IndentPPDirectives: BeforeHash
|
|
16
|
+
|
|
17
|
+
# Braces and blocks
|
|
18
|
+
BreakBeforeBraces: Stroustrup
|
|
19
|
+
AllowShortIfStatementsOnASingleLine: false
|
|
20
|
+
AllowShortLoopsOnASingleLine: false
|
|
21
|
+
AllowShortFunctionsOnASingleLine: Empty
|
|
22
|
+
AllowShortBlocksOnASingleLine: Never
|
|
23
|
+
AllowShortBracesOnASingleLine: false
|
|
24
|
+
AllowShortEnumsOnASingleLine: false
|
|
25
|
+
AllowShortRecordsOnASingleLine: false
|
|
26
|
+
AlwaysBreakAfterReturnType: All
|
|
27
|
+
|
|
28
|
+
# Spaces
|
|
29
|
+
SpaceBeforeParens: ControlStatements
|
|
30
|
+
SpacesInParentheses: false
|
|
31
|
+
SpacesInSquareBrackets: false
|
|
32
|
+
SpaceAfterCStyleCast: true
|
|
33
|
+
SpaceBeforeAssignmentOperators: true
|
|
34
|
+
SpaceBeforeCaseColon: false
|
|
35
|
+
SpaceBeforeRangeBasedForLoopColon: true
|
|
36
|
+
SpaceBeforeInheritanceColon: true
|
|
37
|
+
SpaceBeforeCtorInitializerColon: true
|
|
38
|
+
SpaceBeforeParensOptions:
|
|
39
|
+
AfterControlStatements: true
|
|
40
|
+
AfterForeachMacros: true
|
|
41
|
+
AfterFunctionDeclarationName: false
|
|
42
|
+
AfterFunctionDefinitionName: false
|
|
43
|
+
AfterIfMacros: true
|
|
44
|
+
AfterOverloadedOperator: false
|
|
45
|
+
AfterRequiresInClause: true
|
|
46
|
+
AfterRequiresInExpression: true
|
|
47
|
+
|
|
48
|
+
# Pointer and reference alignment
|
|
49
|
+
PointerAlignment: Right
|
|
50
|
+
DerivePointerAlignment: false
|
|
51
|
+
|
|
52
|
+
# Includes
|
|
53
|
+
SortIncludes: false
|
|
54
|
+
|
|
55
|
+
# Comments
|
|
56
|
+
ReflowComments: true
|
|
57
|
+
|
|
58
|
+
# Misc
|
|
59
|
+
InsertTrailingCommas: None
|
|
60
|
+
InsertBraces: true
|
|
61
|
+
InsertNewlineAtEOF: true
|
|
62
|
+
KeepEmptyLinesAtTheStartOfBlocks: false
|
|
63
|
+
MaxEmptyLinesToKeep: 1
|
|
64
|
+
|
|
65
|
+
# Function declaration/definition
|
|
66
|
+
AlwaysBreakAfterDefinitionReturnType: None
|
|
67
|
+
BreakAfterAttributes: Leave
|
|
68
|
+
|
|
69
|
+
# Macro formatting (cannot enforce PEP 7's macro idioms, but keep formatting clean)
|
|
70
|
+
AllowShortCaseLabelsOnASingleLine: false
|
|
71
|
+
...
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
BasedOnStyle: Google
|
|
75
|
+
Language: Cpp
|
|
76
|
+
|
|
77
|
+
# Indentation and whitespace
|
|
78
|
+
IndentWidth: 4
|
|
79
|
+
TabWidth: 4
|
|
80
|
+
UseTab: Never
|
|
81
|
+
ColumnLimit: 79
|
|
82
|
+
ContinuationIndentWidth: 4
|
|
83
|
+
IndentCaseLabels: true
|
|
84
|
+
IndentGotoLabels: false
|
|
85
|
+
IndentPPDirectives: BeforeHash
|
|
86
|
+
|
|
87
|
+
# Braces and blocks
|
|
88
|
+
BreakBeforeBraces: Stroustrup
|
|
89
|
+
AllowShortIfStatementsOnASingleLine: false
|
|
90
|
+
AllowShortLoopsOnASingleLine: false
|
|
91
|
+
AllowShortFunctionsOnASingleLine: Empty
|
|
92
|
+
AllowShortBlocksOnASingleLine: Never
|
|
93
|
+
AllowShortBracesOnASingleLine: false
|
|
94
|
+
AllowShortEnumsOnASingleLine: false
|
|
95
|
+
AllowShortRecordsOnASingleLine: false
|
|
96
|
+
AlwaysBreakAfterReturnType: All
|
|
97
|
+
|
|
98
|
+
# Spaces
|
|
99
|
+
SpaceBeforeParens: ControlStatements
|
|
100
|
+
SpacesInParentheses: false
|
|
101
|
+
SpacesInSquareBrackets: false
|
|
102
|
+
SpaceAfterCStyleCast: true
|
|
103
|
+
SpaceBeforeAssignmentOperators: true
|
|
104
|
+
SpaceBeforeCaseColon: false
|
|
105
|
+
SpaceBeforeRangeBasedForLoopColon: true
|
|
106
|
+
SpaceBeforeInheritanceColon: true
|
|
107
|
+
SpaceBeforeCtorInitializerColon: true
|
|
108
|
+
SpaceBeforeParensOptions:
|
|
109
|
+
AfterControlStatements: true
|
|
110
|
+
AfterForeachMacros: true
|
|
111
|
+
AfterFunctionDeclarationName: false
|
|
112
|
+
AfterFunctionDefinitionName: false
|
|
113
|
+
AfterIfMacros: true
|
|
114
|
+
AfterOverloadedOperator: false
|
|
115
|
+
AfterRequiresInClause: true
|
|
116
|
+
AfterRequiresInExpression: true
|
|
117
|
+
|
|
118
|
+
# Pointer and reference alignment
|
|
119
|
+
PointerAlignment: Right
|
|
120
|
+
DerivePointerAlignment: false
|
|
121
|
+
|
|
122
|
+
# Includes
|
|
123
|
+
SortIncludes: false
|
|
124
|
+
|
|
125
|
+
# Comments
|
|
126
|
+
ReflowComments: true
|
|
127
|
+
|
|
128
|
+
# Misc
|
|
129
|
+
InsertTrailingCommas: None
|
|
130
|
+
InsertBraces: true
|
|
131
|
+
InsertNewlineAtEOF: true
|
|
132
|
+
KeepEmptyLinesAtTheStartOfBlocks: false
|
|
133
|
+
MaxEmptyLinesToKeep: 1
|
|
134
|
+
|
|
135
|
+
# Function declaration/definition
|
|
136
|
+
AlwaysBreakAfterDefinitionReturnType: None
|
|
137
|
+
BreakAfterAttributes: Leave
|
|
138
|
+
|
|
139
|
+
# Macro formatting (cannot enforce PEP 7's macro idioms, but keep formatting clean)
|
|
140
|
+
AllowShortCaseLabelsOnASingleLine: false
|
|
141
|
+
...
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
name: 🐍 Build Wheels & Publish Python Package
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
tags:
|
|
5
|
+
- 'v*.*.*'
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: write
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
build:
|
|
12
|
+
runs-on: ${{ matrix.os }}
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
16
|
+
env:
|
|
17
|
+
CIBW_OUTPUT_DIR: dist
|
|
18
|
+
CIBW_SKIP: ""
|
|
19
|
+
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-* cp313-*"
|
|
20
|
+
steps:
|
|
21
|
+
- name: Check out code
|
|
22
|
+
uses: actions/checkout@v4
|
|
23
|
+
|
|
24
|
+
- name: Setup Python & build tools
|
|
25
|
+
uses: actions/setup-python@v5
|
|
26
|
+
with:
|
|
27
|
+
python-version: "3.x"
|
|
28
|
+
|
|
29
|
+
- name: Install build dependencies
|
|
30
|
+
run: |
|
|
31
|
+
python -m pip install --upgrade pip build cibuildwheel[global]
|
|
32
|
+
|
|
33
|
+
- name: Build wheels
|
|
34
|
+
run: |
|
|
35
|
+
python -m cibuildwheel
|
|
36
|
+
|
|
37
|
+
- name: Build source‐dist
|
|
38
|
+
run: |
|
|
39
|
+
python -m build --sdist --outdir dist
|
|
40
|
+
|
|
41
|
+
- name: Upload all artifacts
|
|
42
|
+
uses: actions/upload-artifact@v4
|
|
43
|
+
with:
|
|
44
|
+
name: wheels-${{ matrix.os }}
|
|
45
|
+
path: dist
|
|
46
|
+
|
|
47
|
+
release:
|
|
48
|
+
name: Attach & Publish
|
|
49
|
+
needs: build
|
|
50
|
+
runs-on: ubuntu-latest
|
|
51
|
+
env:
|
|
52
|
+
TWINE_USERNAME: __token__
|
|
53
|
+
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
|
|
54
|
+
|
|
55
|
+
steps:
|
|
56
|
+
- name: Download built wheels & sdist
|
|
57
|
+
uses: actions/download-artifact@v4
|
|
58
|
+
with:
|
|
59
|
+
path: dist
|
|
60
|
+
|
|
61
|
+
- name: Flaten dist folder
|
|
62
|
+
run: |
|
|
63
|
+
for d in dist/wheels-*-latest; do
|
|
64
|
+
cp "$d"/*.whl dist/
|
|
65
|
+
done
|
|
66
|
+
|
|
67
|
+
tarball=$(find dist/wheels-*-latest -type f -name 'cbits-*.tar.gz' | head -n1)
|
|
68
|
+
if [ -z "$tarball" ]; then
|
|
69
|
+
echo "Fehler: kein cbits-*.tar.gz gefunden!" >&2
|
|
70
|
+
exit 1
|
|
71
|
+
fi
|
|
72
|
+
cp "$tarball" dist/
|
|
73
|
+
|
|
74
|
+
rm -rf dist/wheels-*-latest
|
|
75
|
+
|
|
76
|
+
- name: List all files in dist
|
|
77
|
+
run: |
|
|
78
|
+
echo "=== Contents of dist ==="
|
|
79
|
+
ls -lhR dist
|
|
80
|
+
|
|
81
|
+
- name: Create GitHub Release assets
|
|
82
|
+
uses: softprops/action-gh-release@v1
|
|
83
|
+
with:
|
|
84
|
+
tag_name: ${{ github.ref_name }}
|
|
85
|
+
files: dist/*
|
|
86
|
+
|
|
87
|
+
- name: Publish to PyPI
|
|
88
|
+
if: env.TWINE_PASSWORD != ''
|
|
89
|
+
uses: pypa/gh-action-pypi-publish@v1.12.4
|
|
90
|
+
with:
|
|
91
|
+
user: ${{ env.TWINE_USERNAME }}
|
|
92
|
+
password: ${{ env.TWINE_PASSWORD }}
|
|
93
|
+
name: Publish to PyPI
|
|
94
|
+
skip-existing: true
|
|
95
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
name: Deploy Doxygen 🚀
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
publish:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: write
|
|
13
|
+
steps:
|
|
14
|
+
- name: Checkout
|
|
15
|
+
uses: actions/checkout@v3
|
|
16
|
+
with:
|
|
17
|
+
fetch-depth: 0
|
|
18
|
+
|
|
19
|
+
- name: Install dependencies
|
|
20
|
+
run: |
|
|
21
|
+
sudo apt-get update
|
|
22
|
+
sudo apt-get install -y doxygen graphviz
|
|
23
|
+
|
|
24
|
+
- name: Build Doxygen HTML
|
|
25
|
+
run: doxygen Doxyfile
|
|
26
|
+
|
|
27
|
+
- name: Show generated files
|
|
28
|
+
run: ls -R doxygen
|
|
29
|
+
|
|
30
|
+
- name: Publish to GitHub Pages
|
|
31
|
+
uses: peaceiris/actions-gh-pages@v4
|
|
32
|
+
with:
|
|
33
|
+
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
34
|
+
publish_dir: doxygen/html
|
|
35
|
+
publish_branch: docs
|
cbits-0.1.1/.gitignore
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
.pypirc
|
|
4
|
+
/dist/
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
*.pyd
|
|
9
|
+
|
|
10
|
+
# Distribution / packaging
|
|
11
|
+
build/
|
|
12
|
+
dist/
|
|
13
|
+
*.egg-info/
|
|
14
|
+
*.egg
|
|
15
|
+
*.whl
|
|
16
|
+
pip-wheel-metadata/
|
|
17
|
+
*.egg-info/
|
|
18
|
+
eggs/
|
|
19
|
+
|
|
20
|
+
# Virtual environments
|
|
21
|
+
env/
|
|
22
|
+
venv/
|
|
23
|
+
.venv/
|
|
24
|
+
ENV/
|
|
25
|
+
env.bak/
|
|
26
|
+
venv.bak/
|
|
27
|
+
|
|
28
|
+
# CMake build directories and files
|
|
29
|
+
CMakeFiles/
|
|
30
|
+
CMakeCache.txt
|
|
31
|
+
cmake_install.cmake
|
|
32
|
+
CMakeLists.txt.user
|
|
33
|
+
Makefile
|
|
34
|
+
build-*/
|
|
35
|
+
|
|
36
|
+
# IDE / editor directories and files
|
|
37
|
+
.vscode/
|
|
38
|
+
.idea/
|
|
39
|
+
*.sublime-project
|
|
40
|
+
*.sublime-workspace
|
|
41
|
+
|
|
42
|
+
# Documentation build
|
|
43
|
+
doxygen
|
|
44
|
+
Doxyfile.bak
|
cbits-0.1.1/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# CHANGELOG
|
|
2
|
+
## [0.1.1]
|
|
3
|
+
### Added
|
|
4
|
+
- Introduce `compat_dispatch.c` for runtime CPU feature detection and automatic selection of the fastest popcount implementation.
|
|
5
|
+
- Additional unit tests
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
- Refactor `compat.h` dispatch logic to clarify fallback paths and cleanup macros.
|
|
9
|
+
|
|
10
|
+
## [0.1.0]
|
|
11
|
+
### Added
|
|
12
|
+
- C backend with SIMD popcount support
|
|
13
|
+
- Python sequence and numeric protocol support (`getitem`, `and`, `or`, etc.)
|
|
14
|
+
- Unit tests for all methods
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.15)
|
|
2
|
+
project(cbits LANGUAGES C)
|
|
3
|
+
|
|
4
|
+
include(CheckCCompilerFlag)
|
|
5
|
+
|
|
6
|
+
set(MODULE_NAME "_cbits")
|
|
7
|
+
|
|
8
|
+
if(DEFINED ENV{VIRTUAL_ENV})
|
|
9
|
+
message(STATUS "Using Python from VIRTUAL_ENV=$ENV{VIRTUAL_ENV}")
|
|
10
|
+
set(Python_ROOT_DIR "$ENV{VIRTUAL_ENV}")
|
|
11
|
+
set(Python_FIND_STRATEGY LOCATION)
|
|
12
|
+
endif()
|
|
13
|
+
|
|
14
|
+
if(APPLE)
|
|
15
|
+
set(Python_FIND_FRAMEWORK NEVER)
|
|
16
|
+
endif()
|
|
17
|
+
|
|
18
|
+
find_package(Python
|
|
19
|
+
COMPONENTS Interpreter Development.Module
|
|
20
|
+
REQUIRED
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
message(STATUS "Found Python ${Python_VERSION_STRING}")
|
|
24
|
+
message(STATUS " Executable: ${Python_EXECUTABLE}")
|
|
25
|
+
message(STATUS " Include dir: ${Python_INCLUDE_DIRS}")
|
|
26
|
+
message(STATUS " Libraries: ${Python_LIBRARIES}")
|
|
27
|
+
message(STATUS " Module ext: ${Python_MODULE_EXTENSION}")
|
|
28
|
+
|
|
29
|
+
add_library(${MODULE_NAME} MODULE
|
|
30
|
+
src/bitvector.c
|
|
31
|
+
src/compat_dispatch.c
|
|
32
|
+
python/binding.c
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
set_target_properties(${MODULE_NAME} PROPERTIES
|
|
36
|
+
PREFIX ""
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
target_include_directories(${MODULE_NAME}
|
|
40
|
+
PRIVATE
|
|
41
|
+
${Python_INCLUDE_DIRS}
|
|
42
|
+
${CMAKE_SOURCE_DIR}/include
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
target_link_libraries(${MODULE_NAME}
|
|
46
|
+
PRIVATE
|
|
47
|
+
Python::Module
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
if (MSVC)
|
|
51
|
+
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
52
|
+
target_compile_options(_cbits PRIVATE /O2 /arch:AVX2)
|
|
53
|
+
target_compile_definitions(_cbits PRIVATE
|
|
54
|
+
__AVX2__=1
|
|
55
|
+
)
|
|
56
|
+
check_c_compiler_flag("/arch:AVX512VPOPCNTDQ" HAS_AVX512VPOPCNTDQ)
|
|
57
|
+
if(HAS_AVX512VPOPCNTDQ)
|
|
58
|
+
target_compile_options(_cbits PRIVATE /arch:AVX512VPOPCNTDQ)
|
|
59
|
+
target_compile_definitions(_cbits PRIVATE __AVX512VPOPCNTDQ__=1)
|
|
60
|
+
endif()
|
|
61
|
+
else()
|
|
62
|
+
target_compile_options(_cbits PRIVATE /O2)
|
|
63
|
+
endif()
|
|
64
|
+
set_target_properties(${MODULE_NAME} PROPERTIES SUFFIX ".pyd")
|
|
65
|
+
else()
|
|
66
|
+
if(CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
|
67
|
+
target_compile_definitions(${MODULE_NAME} PRIVATE USE_X86_INTRINSIC)
|
|
68
|
+
target_compile_options(${MODULE_NAME} PRIVATE
|
|
69
|
+
-O3 -funroll-loops -mavx2 -mavx512vpopcntdq
|
|
70
|
+
)
|
|
71
|
+
else()
|
|
72
|
+
target_compile_options(${MODULE_NAME} PRIVATE -O3)
|
|
73
|
+
endif()
|
|
74
|
+
set_target_properties(${MODULE_NAME} PROPERTIES SUFFIX ".so")
|
|
75
|
+
endif()
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
install(TARGETS ${MODULE_NAME}
|
|
79
|
+
LIBRARY DESTINATION cbits
|
|
80
|
+
RUNTIME DESTINATION cbits
|
|
81
|
+
ARCHIVE DESTINATION cbits
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
install(FILES ${CMAKE_SOURCE_DIR}/python/cbits/__init__.py
|
|
85
|
+
DESTINATION cbits
|
|
86
|
+
)
|