Skip to content

Conversation

@thejtshow
Copy link
Contributor

@thejtshow thejtshow 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')

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

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

@thejtshow thejtshow requested a review from aardappel November 11, 2025 16:23
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