Skip to main content

A collection of frequently used (mostly functional) utilities not found in the standard library

Project description

Generic-Util

Documentation Status PyPI Version PyPI Downloads Python Versions License Actions Status

This package contains convenient functions not found in Python's Standard Library (they would mostly fall within itertools, functools, operator, and time). It also contains a variety of convenience functions for the numba JIT compiler library.

See the documentation for details, but functions are grouped as follows:

  • Generic_Util.benchmarking: functions covering typical code-timing scenarios, such as a "with" statement context, an n-executions timer, and a convenient function for comparing and summarising n execution times of different implementations of the same function.
  • Generic_Util.iter: iterable-focussed functions, covering multiple varieties of flattening, iterable combining, grouping and predicate/property-based processing (including topological sorting), element-comparison-based operations, value interspersal, and finally batching.
  • Generic_Util.operator: functions regarding item retrieval, and syntactic sugar for patterns of function application.
  • Generic_Util.misc: functions with less generic purpose than in the above; currently mostly to do with min/max-based operations.

Then a sub-package is dedicated to utility functions for the numba JIT compiler library:

  • Generic_Util.numba.benchmarking: functions comparing execution times of (semi-automatically-generated) varieties of numba-compilations of a given function, including lazy vs eager compilation, vectorisation, parallelisation, as well as varieties of rolling (see Generic_Util.numba.higher_order).
  • Generic_Util.numba.higher_order: higher-order numba-compilation functions, currently only functions to "roll" simpler functions (1d-to-scalar or 2d-to-scalar/1d) over arrays, with a few combinations of input and output type signatures.
  • Generic_Util.numba.types: convenient shorthands for frequently used numba (and respective numpy) types, with a focus on C-contiguity of arrays; these are useful in declaring eager-compilation function signatures.

Many functions which would have been included in this package were dropped in favour of using those in the wonderful more-itertools package (and where overlaps remain, there are convenient differences). Separately, although used only in one instance in this repository, the sortedcontainers package is another great source of algorithm-simplifying ingredients.

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

generic_util-0.1.0.tar.gz (24.4 kB view details)

Uploaded Source

Built Distribution

generic_util-0.1.0-py3-none-any.whl (20.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: generic_util-0.1.0.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for generic_util-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6d8524986de8cb6353f8c36e73b85d375b50d65408ebb2d2dc3de594711c7670
MD5 7ab49488f6642da1e7284aa66eee541a
BLAKE2b-256 9adc676bd5f0c1e0412e7da97a7d88fcca45e7049657b97b62143da70ddc39cd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: generic_util-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.3

File hashes

Hashes for generic_util-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a36ca850e482423b2b5ead8946d106edf0329aa9fdc948fd633251681b0e2cb
MD5 fd3a8211c392eed6a876520ee181d627
BLAKE2b-256 89053485533b43e86ab43f4b316222b92fe72441526cc4ae05791eddd7edf0d2

See more details on using hashes here.

Supported by

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