RisinT96 commented on issue #3506:
URL: https://github.com/apache/fory/issues/3506#issuecomment-4121080493
I used some AI tools to try and find a root cause for this, what I got is
that the python serializer ignores the `False` in the generated
```python
nested: List[Ref[SomeType, False]] = pyfory.field(id=1, default_factory=list)
```
And uses refcounting anyway as it's enabled globally for fory in the
autogenerated:
```python
def _create_fory() -> pyfory.Fory:
fory = pyfory.Fory(xlang=True, ref=True, compatible=True)
register_repro_fory_crosslang_mismatch_types(fory)
return fory
```
You can take a look at
[this](https://github.com/RisinT96/fory/commit/09408ae8ba2b8a02162781fd060d397b242cdc0c)
commit for the full analysis in the message and a proposed fix in the commit
itself.
I have validated that the fix works locally, and generates a much smaller
binary output for some reason:
```
pyth_len=52
pyth_hex=02001c0006810170805ab647011c66c41670020c28302d393632363762663904bf39000028312d626664303533333004f2650000
```
and rust deserializes it correctly:
```rust
let bytes =
"02001c0006810170805ab647011c66c41670020c28302d393632363762663904bf39000028312d626664303533333004f2650000";
let deserialized = OtherType::from_bytes(&hex::decode(bytes).expect("decode
hex"));
if let Ok(deserialized) = deserialized {
println!("equal? {}", deserialized == nested);
]
```
I don't have the time to fully validate the changes, but you can take that
commit as reference.
Locally I worked around the issue by explicitly setting `ref=False` in
`_create_fory`.
Tal
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]