We can eliminate CRC computation completely, no extra dependencies necessary. The result of the method get_dsdl_signature is dependent only on the definition of its data type, which can't change while the program is running. So I propose to keep the current CRC computation algorithm unchanged, but cache the output of get_dsdl_signature; alternatively, we can compute the signature when the object is constructed and keep the result; in that case, get_dsdl_signature will just return the precomputed result.
I have a better proposition. Consider the result of profiling you shared yesterday:
We can eliminate CRC computation completely, no extra dependencies necessary. The result of the method
get_dsdl_signature
is dependent only on the definition of its data type, which can't change while the program is running. So I propose to keep the current CRC computation algorithm unchanged, but cache the output ofget_dsdl_signature
; alternatively, we can compute the signature when the object is constructed and keep the result; in that case,get_dsdl_signature
will just return the precomputed result.A fair bit of computation is happening also here in
get_data_type_signature
: https://github.com/UAVCAN/pyuavcan/blob/0fd4122fe6e128aabd00d5ca88aba5cc82518c9c/uavcan/dsdl/parser.py#L304-L318 We could apply caching or precomputation here as well.