Skip to main content

LQFT Engine: native C extension with structural sharing and improved unique-value write batching

Project description

Log-Quantum Fractal Tree (LQFT)

Python 3.12 C-Engine Concurrency Architecture License

Project Overview

The Log-Quantum Fractal Tree (LQFT) is a native Python extension that combines HAMT-style routing with structural sharing. The project is still interesting as a systems exercise and as a specialized persistent structure, but the benchmark results in this repository do not support a general claim that LQFT is faster than mainstream in-memory structures in practice.


Release Note (v1.1.5)

This release keeps the paired key/value batching patch.

What improved:

  • Unique-value write throughput improved materially versus the previous local baseline.
  • The improvement is strongest in pure-write workloads, especially at 4 and 8 threads.

What did not improve:

  • LQFT is still not generally competitive with Python dict or straightforward hash-table implementations.
  • Read-heavy workloads are still weaker than mainstream alternatives.
  • Mixed workloads improved only slightly or remained benchmark-dependent.

Practical claim for this release:

  • v1.1.5 is a better write-heavy LQFT than v1.0.9.
  • v1.1.5 is not a proof that LQFT beats common in-memory data structures overall.

Performance Snapshot (v1.1.5)

Verified environment: Windows workstation, Python 3.14 local build, native extension compiled in-place, benchmark matrix used during development before packaging cleanup.

Metric Current Observation Architectural Driver
Pure Write Throughput Improved strongly vs. v1.0.9/local baseline Native paired key/value batching for unique-value writes
Pure Read Throughput Still workload-dependent and behind dict/hash-table peers Traversal cost + concurrency overhead
Mixed Throughput Improved modestly at best Write batching helps, but read-side costs still dominate
Memory Density Tracked at runtime via estimated_native_bytes / physical_nodes Real node bytes + active child arrays + pooled values
Practical Competitiveness Not generally competitive yet Constant-factor overhead still too high

Benchmark note: throughput is workload- and environment-dependent. The release claim for this package should stay conservative and centered on write-heavy improvement rather than broad superiority.

Core Architecture

1. Hardware Synchronization (Thread Affinity & NUMA)

The LQFT explicitly pins OS threads to physical CPU cores to prevent scheduler migrations, guaranteeing that hot memory paths remain in the L1/L2 cache. Memory is mapped using MAP_POPULATE and VirtualAlloc to guarantee NUMA-local hardware proximity.

2. Lock-Free Search & Optimistic Concurrency

Read operations are 100% lock-free (RCU-inspired). Threads traverse the trie without acquiring mutexes or triggering atomic cache-line invalidations. Deallocations are deferred to Thread-Local Retirement Chains, eliminating global contention.

3. Scale-Invariant Big-O Complexity

The LQFT utilizes a fixed 64-bit hash space partitioned into 13 segments.

  • Time Complexity: $O(1)$ — Every traversal requires exactly 13 hardware instructions.
  • Space Complexity: $O(\Sigma)$ — Identical branches are folded into single pointers, mapping physical space to data entropy rather than data volume.

Getting Started

Installation

For normal users, install the published wheel directly from PyPI:

pip install lqft-python-engine

If a wheel is not available for your platform, pip will fall back to a source build. In that case you need a working C compiler toolchain (GCC/MinGW or MSVC).

# Clone the repository
git clone [https://github.com/ParjadM/Log-Quantum-Fractal-Tree-LQFT-.git](https://github.com/ParjadM/Log-Quantum-Fractal-Tree-LQFT-.git)
cd Log-Quantum-Fractal-Tree-LQFT-

# Build the native C-extension locally
python setup.py build_ext --inplace

Python Wrapper

The project is normally used through the wrapper, not by calling the C module directly.

from lqft_engine import LQFT

lqft = LQFT()
lqft.insert("alpha", "value-a")
lqft.insert("beta", "value-b")

result = lqft.search("alpha")
present = lqft.contains("beta")

metrics = lqft.get_stats()
print(result, present, metrics["physical_nodes"])

License

MIT License - Parjad Minooei (2026).

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

lqft_python_engine-1.1.5.tar.gz (18.6 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

lqft_python_engine-1.1.5-cp312-cp312-win_amd64.whl (26.1 kB view details)

Uploaded CPython 3.12Windows x86-64

lqft_python_engine-1.1.5-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (74.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

lqft_python_engine-1.1.5-cp312-cp312-macosx_11_0_arm64.whl (24.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

lqft_python_engine-1.1.5-cp312-cp312-macosx_10_9_x86_64.whl (26.3 kB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

lqft_python_engine-1.1.5-cp311-cp311-win_amd64.whl (26.2 kB view details)

Uploaded CPython 3.11Windows x86-64

lqft_python_engine-1.1.5-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (74.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

lqft_python_engine-1.1.5-cp311-cp311-macosx_11_0_arm64.whl (24.4 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

lqft_python_engine-1.1.5-cp311-cp311-macosx_10_9_x86_64.whl (26.0 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

lqft_python_engine-1.1.5-cp310-cp310-win_amd64.whl (26.2 kB view details)

Uploaded CPython 3.10Windows x86-64

lqft_python_engine-1.1.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (73.4 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

lqft_python_engine-1.1.5-cp310-cp310-macosx_11_0_arm64.whl (24.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

lqft_python_engine-1.1.5-cp310-cp310-macosx_10_9_x86_64.whl (26.0 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

File details

Details for the file lqft_python_engine-1.1.5.tar.gz.

File metadata

  • Download URL: lqft_python_engine-1.1.5.tar.gz
  • Upload date:
  • Size: 18.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for lqft_python_engine-1.1.5.tar.gz
Algorithm Hash digest
SHA256 4a6803b2273268dc7070c5be84623d4388f3b7430ff875769bedaa29de0a2d28
MD5 c0cd53c4b5ace360785784957aea6d2a
BLAKE2b-256 3adaf96ab90185c3701f79ae748d5f6424f9a2f0df36806575729c6fa5c534ce

See more details on using hashes here.

File details

Details for the file lqft_python_engine-1.1.5-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for lqft_python_engine-1.1.5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 e261d8ef17ec9b99a344791e4f5cc92e0e38208b7e9fda76ef0b56dbac32ba09
MD5 50bd7eea2282baa4f80469bd6ba215c3
BLAKE2b-256 de4bb8eb08926c47b8dd96a2d84dedba4647ea18ce4a7b6bae605b55a1a574e3

See more details on using hashes here.

File details

Details for the file lqft_python_engine-1.1.5-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lqft_python_engine-1.1.5-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 74bf595b977412430c6a6dad0ed8a19c4a3fc0534dfe062f2f4ed0bbae43375c
MD5 9912c09e0481e5264a557602670ebe86
BLAKE2b-256 23a0b1c65cd470e955037e9a5c43b7d4b8c9748178bd91214c2b7d426190e1e1

See more details on using hashes here.

File details

Details for the file lqft_python_engine-1.1.5-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lqft_python_engine-1.1.5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cb94f1f93a267263abb0fb2d05d4c5c7237f9960e7db90a88c85e2bdf455f3b3
MD5 218b4dbe98154111cea4be1e83168e57
BLAKE2b-256 493fb2248c05f75a6520a729468fdeb5f0afba1087afd91e4fffbafa1380fa48

See more details on using hashes here.

File details

Details for the file lqft_python_engine-1.1.5-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for lqft_python_engine-1.1.5-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bfc81c7e6a109a8a034c5e1c646597f3417ef877d247d8fa6c2ed863a4779ec7
MD5 37769a7b686ae65b16d7152ab669f8e6
BLAKE2b-256 cf17e564c5c728e4363fec6c128b2e7d994a95e413b5911355ce4b99a6260500

See more details on using hashes here.

File details

Details for the file lqft_python_engine-1.1.5-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for lqft_python_engine-1.1.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 531cddd23cb1d8e406f03d67092e16d36e2b36af5d8da4b48491273ee92e86e9
MD5 b9758af6e5086b5ea2ba84575d25496b
BLAKE2b-256 6c76402cf3fdd3958cf9f2e16871b9a9f694dde1606dc320a804fca05caff01a

See more details on using hashes here.

File details

Details for the file lqft_python_engine-1.1.5-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lqft_python_engine-1.1.5-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 68a39e5023f916f1bf82b2b286ac518f0ca52bf19186f7af8e88657d9094490b
MD5 9f6834c5e733f2e59f3b271f48c4a737
BLAKE2b-256 997df36beff93f3cb5a58105e1ef84bbc02880e8c0f08f1023bf9ae080ba1c14

See more details on using hashes here.

File details

Details for the file lqft_python_engine-1.1.5-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lqft_python_engine-1.1.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 53988bca83a4f5011bb5947efe079266150771e8c86f9d0784f7f3545c7bb312
MD5 388a8eb8f1afd1af5174ef9c37682926
BLAKE2b-256 2cd6a30b5bb4a7e8404616754025a6481528c2e226e7a973de6a8f95534cb79d

See more details on using hashes here.

File details

Details for the file lqft_python_engine-1.1.5-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for lqft_python_engine-1.1.5-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 fba6ef57fc96be532b83627a99c11114dad51f15592705d4b7a5477a98fb9efd
MD5 1801081d9178bc9e0a2fcf6e86987940
BLAKE2b-256 1359cc40183b5b39aa0a6cf5dacaa86d35161c5570c53a10dfada936f19a5869

See more details on using hashes here.

File details

Details for the file lqft_python_engine-1.1.5-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for lqft_python_engine-1.1.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 690af4571b67e0ae3485a1c91a0227855d1b5d02a88b6b699585a6ad969f9b9a
MD5 3fd7995112463e6bef066618bbe52790
BLAKE2b-256 c1baad895dae867ddc965358822caa3753d533cf98a6ce61d0ffa4d2fc47316b

See more details on using hashes here.

File details

Details for the file lqft_python_engine-1.1.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for lqft_python_engine-1.1.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f557668b4ab43b7c7e145c658c10691650f3d9f25d97526b7be3c3397a0760cf
MD5 80cd226bf46577920dc84230bc0d3df8
BLAKE2b-256 c7197906f6153c8015d3e48b4730acb5aeb190fdb3f1e64f26feda38c13ae14e

See more details on using hashes here.

File details

Details for the file lqft_python_engine-1.1.5-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for lqft_python_engine-1.1.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 187ea909a6e52d7260da351249a6df302771443202f5279249bea5b2e1dc1ba9
MD5 010130eb06ee315b4caf8211a4a090e1
BLAKE2b-256 8392a825445c31f63a821aee2dd90d973f5da96ea0350bc0a0a971b067bea87d

See more details on using hashes here.

File details

Details for the file lqft_python_engine-1.1.5-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for lqft_python_engine-1.1.5-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 390b23b9a1c5b8d6aa451a15be51deefe77675a74564ab7636bdea01860c93d0
MD5 dad374333f6b12b875afd8185ecef1cd
BLAKE2b-256 8f29ee0f6373d33ee69a9ee876cb6474011b3bfd51387fa4be8e7ca06fea38ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page