Menu

#66 optimization: use attributes instead of properties

PyXB 2.0.0
new
None
Generation Model
major
PyXB 1.1.0
defect
2009-12-13
2009-12-13
No

The use of Python properties induces an 80% performance penalty over the use of attributes, which makes sense since they add a class attribute lookup plus a method call to the minimal cost of an instance attribute lookup.

A runtime model that uses attributes directly instead of properties should cut execution time by a factor not exceeding 1.8.

A consequence of this will be that passive validation (as fields are assigned) will not be possible, and it will be possible for users to unintentionally overwrite reserved method names (like "value"), preventing the system from working correctly.

Delay or elimination of validation is likely to produce an additional speedup, not currently quantified as it will be dependent on the schema/document involved.

It should be possible to support both modes in the same binding module, with behavior configured at the time the module is loaded. It is not necessary to support changing the mode dynamically as the system is running.

Discussion