Skip to content

Conversation

@ducky64
Copy link
Collaborator

@ducky64 ducky64 commented Nov 29, 2025

Replaces it with populate_x, which is more efficient.

CopyFrom with a ref_map (or any other kind of dict) remains, the data there tends to be small so it's probably the least worst option.

Negligible effect on performance in practice.

Resolves #18

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors the protobuf serialization code to improve performance by replacing CopyFrom() calls with in-place population methods (populate_*) for deeply nested structures. The change eliminates the need to create temporary protobuf objects, instead populating them directly in their final destination.

Key changes:

  • Replaced _expr_to_proto() with _populate_expr_proto() that takes a protobuf object to populate
  • Replaced _decl_to_proto() with _populate_decl_proto() that populates in-place
  • Replaced _instance_to_proto() with _populate_portlike_proto() that populates in-place
  • Removed unused StructuredMetadata base class that is no longer needed

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
edg/core/Ports.py Updated Port classes to use _populate_portlike_proto() and _populate_decl_proto() methods instead of returning proto objects
edg/core/HierarchyBlock.py Changed constraint and parameter initialization to use populate methods
edg/core/Core.py Removed unused StructuredMetadata class and updated metadata type hints
edg/core/ConstraintExpr.py Refactored expression types to use _populate_decl_proto() and _populate_expr_proto() with SetInParent() for optional fields
edg/core/Blocks.py Updated block proto generation to use populate methods for parameters, ports, and constraints
edg/core/Binding.py Comprehensive refactoring of all binding classes to use populate_expr_proto() and populate_literal_proto() methods; made ArrayBinding inherit from Binding instead of LiteralBinding
edg/core/ArrayExpr.py Updated array expression proto generation to use populate methods
edg/core/Array.py Updated array and vector proto generation to use _populate_portlike_proto()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ducky64 ducky64 merged commit 279f944 into master Nov 29, 2025
17 of 18 checks passed
@ducky64 ducky64 deleted the less-copyfrom branch November 29, 2025 02:54
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.

Reduce proto CopyFrom

2 participants