pyTooling is a powerful collection of arbitrary useful classes, decorators, meta-classes and exceptions.
Project description
pyTooling
pyTooling is a powerful collection of arbitrary useful abstract data models, classes, decorators, meta-classes and exceptions. It also provides lots of helper functions e.g. to ease the handling of package descriptions.
It's useful for any Python-base project independent if it's a library, framework or CLI tool.
Introduction
pyTooling is a basic collection of powerful helpers needed by almost any Python project. More specialized helpers can be found in sub-namespaces like:
In addition, pyTooling provides a collection of CI job templates for GitHub Actions. This drastically simplifies GHA-based CI pipelines for Python projects.
Package Details
Common Helper Functions
This is a set of useful helper functions:
- getsizeof calculates the "real" size of a data structure.
- isnestedclass checks if a class is nested inside another class.
- mergedicts merges multiple dictionaries into a new dictionary.
- zipdicts iterate multiple dictionaries simultaneously.
Common Classes
- pyTooling.CallByRef.*
Emulation of call-by-reference parameters. - pyTooling.Versioning.*
Class representations of semantic version (SemVer) and calendar version (CalVer) numbers.
Data Structures
pyTooling also provides fast and powerful data structures offering object-oriented APIs:
- Trees
- Tree data structure
→ A fast and simple implementation using a singleNode
class.
- Tree data structure
Decorators
- Documentation
@InheritDocString
→ Copy the doc-string from given base-class.
- Visibility
@export
→ Register the given function or class as publicly accessible in a module.
Exceptions
- EnvironmentException
... is raised when an expected environment variable is missing. - PlatformNotSupportedException
... is raise if the platform is not supported. - NotConfiguredException
... is raise if the requested setting is not configured.
Meta-Classes
- Overloading
→Overloading
allows method overloading in Python classes. It dispatches method calls based on method signatures (type annotations). - Singleton
→ A class created from meta-classSingleton
allows only a single instance to exist. If a further instance is tried to be created, a cached instance will be returned. - SlottedType
→ All type-annotated fields in a class get stored in a slot rather than in__dict__
. This improves the memory footprint as well as the field access performance of all class instances. The behavior is automatically inherited to all derived classes.
Packaging
tbd
Examples
@export
Decorator
from pyTooling.Decorators import export
@export
class MyClass:
pass
CallByRefIntParam
from pyTooling.CallByRef import CallByRefIntParam
# define a call-by-reference parameter for integer values
myInt = CallByRefIntParam(3)
# a function using a call-by-reference parameter
def func(param: CallByRefIntParam):
param <<= param * 4
# call the function and pass the wrapper object
func(myInt)
print(myInt.Value)
Contributors
- Patrick Lehmann (Maintainer)
- Sven Köhler
- and more...
License
This Python package (source code) licensed under Apache License 2.0.
The accompanying documentation is licensed under Creative Commons - Attribution 4.0 (CC-BY 4.0).
SPDX-License-Identifier: Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for pyTooling-2.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc883f35da8a99d0e0f00aeb91c2dbb1bdcc7859c6e9ddaf8d3ef5c114fdfdff |
|
MD5 | 56b7431d0f8817c0acf6e10fefa5eb14 |
|
BLAKE2b-256 | bfe4b2abd31945e95a2e810703199260be9211a73ed83353281eed8e6ac052e9 |