Skip to content

Avoid multiple component registrations #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
rmorshea opened this issue Aug 19, 2021 · 2 comments · Fixed by #24
Closed

Avoid multiple component registrations #5

rmorshea opened this issue Aug 19, 2021 · 2 comments · Fixed by #24

Comments

@rmorshea
Copy link
Contributor

Since one can use the same component more than once we should avoid calling _register_component more than once if it's already been done. A simple containment check in IDOM_REGISTERED_COMPONENTS should work here.

@Archmonger
Copy link
Contributor

Archmonger commented Aug 19, 2021

Accidentally commented on the wrong issue before, so I'm reposting here


Caching the register function with functools.cache would provide the same ability to skip re-registration, and would allow us to skip the sys.modules check. Could be slightly more performant than checking IDOM_REGISTERED_COMPONENTS.

@Archmonger
Copy link
Contributor

Archmonger commented Aug 31, 2021

Note: recently discovered there is no performance penalty for importing a module more than one time. Apparently importlib already does a sys.modules check. Which means we can remove this LOC.

See here for more details.

Archmonger added a commit to Archmonger/reactpy-django that referenced this issue Sep 22, 2021
@Archmonger Archmonger linked a pull request Sep 22, 2021 that will close this issue
9 tasks
@Archmonger Archmonger linked a pull request Oct 30, 2021 that will close this issue
@Archmonger Archmonger removed a link to a pull request Oct 30, 2021
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants