Skip to content

Conversation

@jtdavis777
Copy link
Collaborator

@jtdavis777 jtdavis777 commented Aug 26, 2025

Fixes #8653

added object size to the vtable lookup tuple.

Problem output:

>>> import python.flatbuffers as flatbuffers
>>> builder = flatbuffers.Builder()
>>> builder.StartObject(1)
>>> builder.PrependInt32Slot(0, 1, 0)
>>> obj1 = builder.EndObject()
>>>     
>>> builder.StartObject(1)
>>> builder.PrependInt64Slot(0, 2, 0)
>>> obj2 = builder.EndObject()
>>> builder.Finish(obj2)
992
>>> builder.Output()
bytearray(b'\x04\x00\x00\x00\xf2\xff\xff\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x00\x08\x00\x04\x00\x06\x00\x00\x00\x01\x00\x00\x00')

Fixed output:

>>> import python.flatbuffers as flatbuffers
>>> builder = flatbuffers.Builder()
>>> builder.StartObject(1)
>>> builder.PrependInt32Slot(0, 1, 0)
>>> obj1 = builder.EndObject()
>>>     
>>> builder.StartObject(1)
>>> builder.PrependInt64Slot(0, 2, 0)
>>> obj2 = builder.EndObject()
>>> builder.Finish(obj2)
984
>>> builder.Output()
bytearray(b'\x0c\x00\x00\x00\x00\x00\x06\x00\x0e\x00\x04\x00\x06\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x06\x00\x08\x00\x04\x00\x06\x00\x00\x00\x01\x00\x00\x00')

@jtdavis777 jtdavis777 force-pushed the fix/python_vtables branch 2 times, most recently from daf8289 to eda12f5 Compare August 29, 2025 12:49
@jtdavis777
Copy link
Collaborator Author

@aardappel could I also trouble you to look over this PR? I don't think the repo has a python maintainer listed.

@jtdavis777 jtdavis777 requested a review from aardappel November 11, 2025 16:23
@aardappel aardappel merged commit e3ee248 into google:master Nov 17, 2025
49 checks passed
@jtdavis777 jtdavis777 deleted the fix/python_vtables branch November 19, 2025 00:14
TJKoury pushed a commit to DigitalArsenal/flatbuffers that referenced this pull request Nov 19, 2025
…oogle#8683)

* have vtables consider size

* simplification from comment

---------

Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
TJKoury pushed a commit to DigitalArsenal/flatbuffers that referenced this pull request Nov 19, 2025
…oogle#8683)

* have vtables consider size

* simplification from comment

---------

Co-authored-by: Wouter van Oortmerssen <aardappel@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Python] Object size is not considered during vtable de-duplication

2 participants