Skip to content

Add fast __deepcopy__ for FT to avoid slow generic object fallback#902

Open
AmiraliOmidvar wants to merge 1 commit into
AnswerDotAI:mainfrom
AmiraliOmidvar:feat/ft-deepcopy
Open

Add fast __deepcopy__ for FT to avoid slow generic object fallback#902
AmiraliOmidvar wants to merge 1 commit into
AnswerDotAI:mainfrom
AmiraliOmidvar:feat/ft-deepcopy

Conversation

@AmiraliOmidvar

Copy link
Copy Markdown

Related Issue
N/A (performance optimization)

Proposed Changes
Add a fast deepcopy implementation for FT (Fast Tag) to avoid the slow generic object fallback. The implementation directly copies the five core fields (tag, children, attrs, void_, listeners_) while delegating unknown attr/child value types to deepcopy itself, so user-defined deepcopy methods are still respected. This improves performance when copying FT components.

Types of changes
What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist
Go over all the following points, and put an x in all the boxes that apply:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I am aware that this is an nbdev project, and I have edited, cleaned, and synced the source notebooks instead of editing .py or .md files directly.

Additional Information
Tests added in nbs/api/00_core.ipynb cover:

  • Basic deepcopy with identity verification
  • Nested structure mutation isolation
  • Void element preservation
  • Custom deepcopy delegation
  • fast_app() header/footer deepcopy

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 this pull request may close these issues.

1 participant