File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -631,6 +631,36 @@ or with a single container ``register_loader_containers(container)`` multiple ti
631
631
To unregister a container use ``unregister_loader_containers(container) ``.
632
632
Wiring module will uninstall the import hook when unregister last container.
633
633
634
+ Few notes on performance
635
+ ------------------------
636
+
637
+ ``.wire() `` utilize caching to speed up the wiring process. At the end it clears the cache to avoid memory leaks.
638
+ But this may not always be desirable, when you want to keep the cache for the next wiring
639
+ (e.g. due to usage of multiple containers or during unit tests).
640
+
641
+ To keep the cache after wiring, you can set flag ``keep_cache=True `` (works with ``WiringConfiguration `` too):
642
+
643
+ .. code-block :: python
644
+
645
+ container1.wire(
646
+ modules = [" yourapp.module1" , " yourapp.module2" ],
647
+ keep_cache = True ,
648
+ )
649
+ container2.wire(
650
+ modules = [" yourapp.module2" , " yourapp.module3" ],
651
+ keep_cache = True ,
652
+ )
653
+ ...
654
+
655
+ and then clear it manually when you need it:
656
+
657
+ .. code-block :: python
658
+
659
+ from dependency_injector.wiring import clear_cache
660
+
661
+ clear_cache()
662
+
663
+
634
664
Integration with other frameworks
635
665
---------------------------------
636
666
You can’t perform that action at this time.
0 commit comments