Currently we end up validating structs multiple times. All the fields of a struct are validated upon construction. But if the struct is then used as an argument to another struct, all fields on that new struct will be validated -- including the already-validated struct. This can be really expensive when a large number of objects is involved, and I wouldn't be surprised if this is significantly hurting our deserialization performance.
foos = [Foo(x) for i in xrange(1000)] # all objects are validated upon construction
bar = Bar(foos=foos) # here they're validated again
One possible solution is to track this in a _validated attribute. It'll have to be set to False when attributes on the object are changed manually using obj.attr = foo.
Currently we end up validating structs multiple times. All the fields of a struct are validated upon construction. But if the struct is then used as an argument to another struct, all fields on that new struct will be validated -- including the already-validated struct. This can be really expensive when a large number of objects is involved, and I wouldn't be surprised if this is significantly hurting our deserialization performance.
One possible solution is to track this in a
_validated
attribute. It'll have to be set to False when attributes on the object are changed manually usingobj.attr = foo
.