Skip to main content

Core Tools for Python Projects

Project description

pycoretools

CI Lint CI Test Coverage Docs PyPI PyPI Downloads Binder Python

pycoretools is a lightweight collection of generic, low-level utilities that are reused across multiple Python projects. It is designed to provide commonly needed building blocks without introducing heavy dependencies or project-specific assumptions.

This package exists primarily to break dependency cycles between higher-level libraries and to centralise small but widely useful tools.


Provided utilities

Concurrency helpers

  • mapThreads: a flexible map-like interface supporting
    • multiprocessing or threading
    • nested parallelism
    • progress reporting
    • optional checkpointing via pickled caches
  • filterThreads: parallelised filtering built on top of mapThreads

These helpers are designed to work robustly in complex environments (e.g. nested pools, daemonic processes).


Context management

  • TemporarySetting: temporarily override a module attribute or namespace entry, e.g.
import syngular
from pycoretools import TemporarySetting

with TemporarySetting(syngular, "TIMEOUT", 3600):
    ...

Useful for safely modifying global or module-level settings locally.


Decorators

  • retry: retry a function call on specified exceptions
  • with_cm: apply a context manager as a decorator

Iterable utilities

  • flatten: controlled flattening of nested iterables, with support for
    • list subclasses
    • NumPy arrays
    • SymPy matrices
    • limited recursion depth
  • crease: inverse operation to flatten, reconstructing nested structure from a template
  • chunks: iterate over fixed-size chunks
  • all_non_empty_subsets: generate all non-empty subsets of an iterable

Sentinels

  • NaI (“Not an Integer”): a singleton sentinel value that propagates through arithmetic operations, akin to NaN (“Not a Number“) for foats.
from pycoretools import NaI

NaI + 3   # NaI
NaI * 10  # NaI

Installation

The package is available on the Python Package Index:

pip install pycoretools

For development:

git clone https://github.com/GDeLaurentis/pycoretools.git
pip install -e pycoretools

Requirements

pycoretools itself depends only on the Python standard library.

Optional behaviour in some utilities may interact with:

  • numpy
  • sympy

These are not required dependencies.

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

pycoretools-0.1.1.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

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

pycoretools-0.1.1-py3-none-any.whl (23.1 kB view details)

Uploaded Python 3

File details

Details for the file pycoretools-0.1.1.tar.gz.

File metadata

  • Download URL: pycoretools-0.1.1.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.3

File hashes

Hashes for pycoretools-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b8eba0bc38b1feac6e01c00a4cf194963e6cdc3161939ca402e37dbcc29b9c2c
MD5 019d003d668b2d03c5341b261343f157
BLAKE2b-256 8da7b0d76bea35ae52b9821c720dbd25e4fa21d6ceb573fc7020ac3bd68250d5

See more details on using hashes here.

File details

Details for the file pycoretools-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pycoretools-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 23.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.3

File hashes

Hashes for pycoretools-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 356644775a3539119e57658ad490762cf26e03eeeb7ede43187a30b6f5fab281
MD5 de900f5b7f2eb6fa711d7bea4b199fd6
BLAKE2b-256 4bf23f74503dc8d334c0fdd780317955d2347bd8c4456e9ed8859c7eb6d28872

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