From 2f331a6840735d32626d77b1e22b0b03c62181b3 Mon Sep 17 00:00:00 2001 From: Juliya Smith Date: Fri, 8 Nov 2024 15:26:59 -0600 Subject: [PATCH] docs: note on perf --- docs/userguides/developing_plugins.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/userguides/developing_plugins.md b/docs/userguides/developing_plugins.md index 199e970cbb..037263b9d8 100644 --- a/docs/userguides/developing_plugins.md +++ b/docs/userguides/developing_plugins.md @@ -61,6 +61,9 @@ from ape import plugins # Here, we register our provider plugin so we can use it in 'ape'. @plugins.register(plugins.ProviderPlugin) def providers(): + # NOTE: By keeping this import local, we avoid slower plugin load times. + from ape_my_plugin.providers import MyProvider + # NOTE: 'MyProvider' defined in a prior code-block. yield "ethereum", "local", MyProvider ``` @@ -69,6 +72,11 @@ This decorator hooks into ape core and ties everything together by looking for a Then, it will loop through these potential `ape` plugins and see which ones have created a plugin type registration. If the plugin type registration is found, then `ape` knows this package is a plugin and attempts to process it according to its registration interface. +```{warning} +Ensure your plugin's `__init__.py` file imports quickly by keeping all expensive imports in the hook functions locally. +This helps Ape register plugins faster, which is required when checking for API implementations. +``` + ### CLI Plugins The `ape` CLI is built using the python package [click](https://palletsprojects.com/p/click/).