[ascl:2511.017]
kdcount: KDTree for low dimensional spatial indexing
kdcount provides a simple API for brute-force spatial pair-counting in low-dimensional data sets using a KD-tree to prune the search space. For a given distance threshold D, kdcount invokes a user-supplied callback for each pair of points whose separation falls within D, enabling custom counting or correlation statistics. The Python interface additionally supports clustering via a Friend-of-Friend algorithm and can exploit shared-memory parallelism with installation of an optional package. Periodic boundary conditions are supported, making kdcount suitable for analyses in periodic domains. While the implementation admits internal “smarter” algorithms, only the standard brute-force mode is tested and documented; the design emphasizes simplicity and flexibility over asymptotic optimality.