2020-09-09 04:57:37 +03:00
|
|
|
.. _key-features:
|
|
|
|
|
2020-07-18 07:40:14 +03:00
|
|
|
Key features
|
|
|
|
------------
|
2016-03-31 00:40:49 +03:00
|
|
|
|
2016-04-11 23:16:46 +03:00
|
|
|
.. meta::
|
2016-04-23 15:00:06 +03:00
|
|
|
:keywords: Python,DI,Dependency injection,IoC,Inversion of Control
|
2020-09-03 20:36:19 +03:00
|
|
|
:description: This article describes key features of the Dependency Injector
|
|
|
|
framework.
|
2016-04-11 23:16:46 +03:00
|
|
|
|
2020-09-03 23:19:40 +03:00
|
|
|
Key features of the ``Dependency Injector``:
|
|
|
|
|
|
|
|
- **Providers**. Provides ``Factory``, ``Singleton``, ``Callable``, ``Coroutine``, ``Object``,
|
2020-10-25 03:56:32 +03:00
|
|
|
``List``, ``Dict``, ``Configuration``, ``Resource``, ``Dependency`` and ``Selector`` providers
|
|
|
|
that help assembling your objects. See :ref:`providers`.
|
2020-09-03 23:19:40 +03:00
|
|
|
- **Overriding**. Can override any provider by another provider on the fly. This helps in testing
|
|
|
|
and configuring dev / stage environment to replace API clients with stubs etc. See
|
|
|
|
:ref:`provider-overriding`.
|
2021-02-03 17:21:32 +03:00
|
|
|
- **Configuration**. Reads configuration from ``yaml`` & ``ini`` files, ``pydantic`` settings,
|
|
|
|
environment variables, and dictionaries. See :ref:`configuration-provider`.
|
2020-10-25 03:56:32 +03:00
|
|
|
- **Resources**. Helps with initialization and configuring of logging, event loop, thread
|
2020-10-30 05:55:09 +03:00
|
|
|
or process pool, etc. Can be used for per-function execution scope in tandem with wiring.
|
|
|
|
See :ref:`resource-provider`.
|
2020-09-03 23:19:40 +03:00
|
|
|
- **Containers**. Provides declarative and dynamic containers. See :ref:`containers`.
|
2020-10-09 22:16:27 +03:00
|
|
|
- **Wiring**. Injects dependencies into functions and methods. Helps integrating with
|
2020-11-13 05:29:22 +03:00
|
|
|
other frameworks: Django, Flask, Aiohttp, Sanic, FastAPI, etc. See :ref:`wiring`.
|
2021-01-11 03:26:15 +03:00
|
|
|
- **Asynchronous**. Supports asynchronous injections. See :ref:`async-injections`.
|
2020-09-14 03:32:21 +03:00
|
|
|
- **Typing**. Provides typing stubs, ``mypy``-friendly. See :ref:`provider-typing`.
|
2020-10-09 22:16:27 +03:00
|
|
|
- **Performance**. Fast. Written in ``Cython``.
|
2020-09-04 01:03:21 +03:00
|
|
|
- **Maturity**. Mature and production-ready. Well-tested, documented and supported.
|
2020-09-03 23:19:40 +03:00
|
|
|
|
2020-10-09 22:16:27 +03:00
|
|
|
The framework stands on the `PEP20 (The Zen of Python) <https://www.python.org/dev/peps/pep-0020/>`_ principle:
|
2020-08-11 05:29:25 +03:00
|
|
|
|
2020-10-09 22:16:27 +03:00
|
|
|
.. code-block:: plain
|
2020-08-11 05:29:25 +03:00
|
|
|
|
2020-10-09 22:16:27 +03:00
|
|
|
Explicit is better than implicit
|
2020-08-11 05:29:25 +03:00
|
|
|
|
2020-10-09 22:16:27 +03:00
|
|
|
You need to specify how to assemble and where to inject the dependencies explicitly.
|
2020-08-11 05:29:25 +03:00
|
|
|
|
2020-10-09 22:16:27 +03:00
|
|
|
The power of the framework is in a simplicity.
|
|
|
|
``Dependency Injector`` is a simple tool for the powerful concept.
|
2020-09-03 23:19:40 +03:00
|
|
|
|
2017-02-28 23:00:08 +03:00
|
|
|
.. disqus::
|