perf: eliminate copy.deepcopy from core state management and notifications#616
perf: eliminate copy.deepcopy from core state management and notifications#616wahh3b-lgtm wants to merge 2 commits into
Conversation
…tions - CoreManager: use dict/list shallow copies for state snapshots, deepcopy for AbstractCore objects in getters - HostManager: use dict() instead of deepcopy for host state snapshots - Subscription share: use model_copy(deep=True) for nested tls_config/transport_config to avoid mutating cached hosts - Discord notifications: replace copy.deepcopy with dict spread + footer clone for 36 notification template copies
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| wireguard_reserved=reserved, | ||
| wireguard_dns=dns, | ||
| fragment_settings=host.fragment_settings.model_dump() if host.fragment_settings else None, | ||
| noise_settings=host.noise_settings.model_dump() if host.noise_settings else None, |
There was a problem hiding this comment.
lol yeah, caused by my autistic ai agent, i will fix it rn
Changes
app/core/manager.py): State snapshots usedict()/list()shallow copies. Getters returndeepcopy()only forAbstractCoreobjects to prevent live state mutationapp/core/hosts.py): Usesdict()instead ofdeepcopy()for host state snapshotsapp/subscription/share.py): Usesmodel_copy(deep=True)for nestedtls_configandtransport_configto prevent mutating cached host datacopy.deepcopy()calls with{**template, "footer": dict(template["footer"])}dict spread patternFiles Changed
app/core/manager.pyapp/core/hosts.pyapp/subscription/share.pyapp/notification/discord/admin.pyapp/notification/discord/admin_role.pyapp/notification/discord/core.pyapp/notification/discord/group.pyapp/notification/discord/host.pyapp/notification/discord/node.pyapp/notification/discord/user.pyapp/notification/discord/user_template.pyVerification