Skip to main content

A light library for general purpose object factories

Project description

objectory = object + factory

CI Nightly Tests Nightly Package Tests Codecov
Documentation Documentation
Code style: black Doc style: google Ruff Doc style: google
PYPI version Python BSD-3-Clause
Downloads Monthly downloads

Overview

A Python library for general purpose object factories. In particular, it focuses on dynamic object factory implementations where objects can be registered dynamically without changing the code of the factory. An object factory can be used to instantiate an object from its configuration. The current implementation contains both abstract factory and registry approaches.

factory

>>> from objectory import factory
>>> obj = factory("builtins.list")
>>> print(obj)
[]
>>> obj = factory("builtins.list", [4, 2])
>>> print(obj)
[4, 2]

abstract factory

>>> from objectory import AbstractFactory
>>> class BaseClass(metaclass=AbstractFactory):
...     pass
...
>>> class MyClass(BaseClass):
...     pass
...
>>> obj = BaseClass.factory("MyClass")
>>> print(obj)
<__main__.MyClass object at 0x...>

registry

>>> from objectory import Registry
>>> registry = Registry()
>>> @registry.register()
... class MyClass:
...     pass
...
>>> obj = registry.factory("MyClass")
>>> print(obj)
<__main__.MyClass object at 0x...>

Please read the documentation to learn more about these approaches.

Installation

We highly recommend installing a virtual environment. objectory can be installed from pip using the following command:

pip install objectory

It is highly recommended to use the last stable version available. Please check the get started page to see other alternatives to install the library. The following is the corresponding objectory versions and supported dependencies.

objectory tornado python
main >=3.10
0.3.1 >=3.10
0.3.0 >=3.10
0.2.2 >=6.0,<7.0 >=3.10,<3.15
0.2.1 >=6.0,<7.0 >=3.10,<3.15
0.2.0 >=6.0,<7.0 >=3.9,<3.14
older versions
objectory tornado python
0.1.2 >=6.0,<7.0 >=3.9,<3.13
0.1.1 >=6.0,<7.0 >=3.9,<3.13
0.1.0 >=6.0,<7.0 >=3.9,<3.13
0.0.9 >=6.0,<7.0 >=3.9,<3.13
0.0.8 >=6.0,<7.0 >=3.9,<3.13
0.0.7 >=6.0,<7.0 >=3.9,<3.12

Contributing

Please check the instructions in CONTRIBUTING.md.

API stability

:warning: While objectory is in development stage, no API is guaranteed to be stable from one release to the next. In fact, it is very likely that the API will change multiple times before a stable 1.0.0 release. In practice, this means that upgrading objectory to a new version will possibly break any code that was using the old version of objectory.

License

objectory is licensed under BSD 3-Clause "New" or "Revised" license available in LICENSE file.

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

objectory-0.3.1.tar.gz (16.6 kB view details)

Uploaded Source

Built Distribution

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

objectory-0.3.1-py3-none-any.whl (20.7 kB view details)

Uploaded Python 3

File details

Details for the file objectory-0.3.1.tar.gz.

File metadata

  • Download URL: objectory-0.3.1.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for objectory-0.3.1.tar.gz
Algorithm Hash digest
SHA256 c3b4f387db31470058d8b34d930daeaacb25eb09384c1e266eaf62ca5b15fc8b
MD5 355cbef36a4e23a105964243b6662b92
BLAKE2b-256 2038f46a0603c7f59ffea5c44d0bd2f484c1ed2ecbd44a0c3b6cd61ef41d781e

See more details on using hashes here.

File details

Details for the file objectory-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: objectory-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 20.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for objectory-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 663a433c7c8ac4971617a61be4f0a9c258bd518bea00bf9eb3f337504ac4c7ce
MD5 1359015a7c00b16e5955c78a37bfacfa
BLAKE2b-256 d54d35db369f225cc44df8fd1a7b06b332da3aefe5ed5b9db512046bf195d0a8

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