Package: fext
Fast CPython extensions to Python standard library with focus on performance.This library provides CPython native extensions to mimic some of the well known
built-in types. The implementation relies on enforced protocol - all the
objects and abstract data types are implemented in C/C++ to provide highly
effective manipulation.Extended heapq - fext.ExtHeapQueueThe extended heap queue acts as a min-heap queue from the standard Python
library.  It uses a hash table for storing information about indexes (where
values sit in the min-heap queue) to optimize removals from the heap
to O(log(N)).Using fext in a C++ projectThe design of this library allows you to use sources in your C++ project as
well. Theeheapq.hppfile defines the extended heap queue andedict.hppthe
extended dictionary. Python files then act as a bindings to their respective
Python interfaces. Mind the API design for the templated classes - it was meant to
be used with pointers to objects (so avoid possible copy constructors).Building the extensionsTo build extensions, install the following packages (Fedora):dnf install -y python3-devel g++ gccNow you can build extensions:python3 setup.py buildIf you would like to produce binaries with debug information:CFLAGS='-Wall -O0 -ggdb' python3 setup.py buildCheck sections below for more info on testing the C/C++ parts of extensions.Reference count and memory leak checksYou can findMakefilein the Git repo. This repo defines targets to
perform leak checks and reference count checks. Note they use different Python
interpreters (with/without debug information) so make sure you do not mix
virtual environments when running the tests.make checkDeveloping the extensionFirst, prepare your environment:dnf install -y make
make depsTo develop or adjust sources, simply change sources and verify your
change is accepted by the test suite:make checkThechecktarget will run the actual test suite (see alsomake test).
Besides it, the test suite will be executed two more times to check test suite
and its behaviour with respect to Python object reference counting
(python3-debugdependency will be automatically installed with the providedmake deps). This part of the test suite can be executed usingmakecheck-refcount. The last part of the test suite runs valgrind against the
test suite - you can explicitly trigger this part by callingmakecheck-leaks.Mindmakecheck-refcountandmakecheck-leakswill take some time given the
checks and processing that is done on the background. To verify your changes
more iterativelly,make testshould do the trick (don’t forget to domake checkafter that though).To clean up your environment, perform:make cleanBuilding and releasingThe release can be done from a containerized environment:podman run --rm --workdir /io --entrypoint bash -it --volume `pwd`:/io:Z quay.io/pypa/manylinux2014_x86_64 -c "yum install -y make && make all"To check what’s happening, let’s run a containerized environment - this can be
helpful when you are testing or developing the extension:podman run --rm --workdir /io --entrypoint bash -it --volume `pwd`:/io:Z quay.io/pypa/manylinux2014_x86_64The following commands (run in the container stated above) will install all
the necessary tools:yum install -y make
make depsOnce tests pass, clean the environment:make cleanNow we should be ready to producebdist_wheelandsdistdistribution
for PyPI:python3 setup.py bdist_wheel
python3 setup.py sdistFinally, upload artifacts to PyPI:auditwheel repair fext/*.whl
twine upload wheelhouse/*.whlAlternativelly you can letmake allhappen.InstallationThe project ishosted on PyPI. You can
install it viapiporPipenv:pipenv install fext#pip3installfextIf there is no release conforming your system, a build process is triggered
during the installation - requirespython3-develandgcc/g++.UsageThese data structures were designed for Thoth’s adviser - for data kept in
resolver’s internal state as well as in the reinforcement learning part.