Skip to main content

Core Tools for Python Projects

Project description

pycoretools

CI Lint CI Test Coverage PyPI 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.0.tar.gz (24.0 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.0-py3-none-any.whl (22.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pycoretools-0.1.0.tar.gz
  • Upload date:
  • Size: 24.0 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.0.tar.gz
Algorithm Hash digest
SHA256 c24b0242f7b0fd201b00c51f5a41544a9537903a30d2965b53aa50e7acf5d848
MD5 1dfcbf143b259c62769ba0f35e613d98
BLAKE2b-256 e38edd58fdc47c34b0be9fbbb5525044f7f8b01b237e4ea30c1ac3e6532d1284

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pycoretools-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 22.2 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d7f0305fa7f2e93a748c2d9150526356886c24db6e766f82fce67e4f3f4dd82a
MD5 ef0dff4f4e284be188d9ff577b019234
BLAKE2b-256 1a60ccf6588d5de88472a2f3ec882e4fb91544c4e64c882b004ce4e3daf3271e

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