Skip to content

Unify nested variant handling #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

Conversation

alamb
Copy link

@alamb alamb commented Jul 14, 2025

This PR targets the following from @friendlymatthew

The high level idea is to handle the low level recursion in ValueBuffer in a uniform way

Then the higher level VariantBuilders simply call into that

I ran out of time today, but I think this approach is pretty promising

@@ -195,7 +194,28 @@ impl ValueBuffer {
self.0.len()
}

fn append_variant<'m, 'd>(&mut self, variant: Variant<'m, 'd>) {
fn new_object<'a>(&'a mut self, metadata_builder: &'a mut MetadataBuilder) -> ObjectBuilder<'a> {
Copy link
Author

Choose a reason for hiding this comment

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

This is the major change - move the low level appending to the ValueBuffer itself

Then all the recursion seems to fall into place

Copy link
Member

@friendlymatthew friendlymatthew left a comment

Choose a reason for hiding this comment

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

Great! I will take a look

@friendlymatthew friendlymatthew merged commit 014ffad into pydantic:friendlymatthew/append-complex Jul 14, 2025
10 of 12 checks passed
friendlymatthew added a commit that referenced this pull request Jul 14, 2025
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.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy