You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 8, 2024. It is now read-only.
I've poked around a bit and read the documentation, and had a question regarding best-practice usage.
The documentation's example for decoding a buffer into an ASN.1 object decodes the buffer into a global instance of a constructed type. This is a global that is mutated for the entire application. Is there a correct/documented way wherein I could decode my data into a private, local instance of the desired type, rather than mutating global state? A simple attempt involving copy.deepcopy seemed to work, but I don't know if that's a good idea or not. The clone method I saw for some types in the repository isn't present on the compiled types.
The text was updated successfully, but these errors were encountered:
You are experiencing a limitation of the ASN.1 runtime (see https://github.com/ANSSI-FR/pycrate/wiki/Compiling-asn1-specifications#limitations, last bullet). Duplicating locally each ASN.1 structures when we want to encode or decode a value would be costly, hence the use of global objects, which _val attribute gets written / read by the application.
Also, I did not write a clone method because of the complexity involved for large objects.
Using deepcopy seems a way (the only easy one ?) to handle this object structure duplication. If you come with a stable and efficient solution, feel free to propose an extension to the current code and documentation.
I've poked around a bit and read the documentation, and had a question regarding best-practice usage.
The documentation's example for decoding a buffer into an ASN.1 object decodes the buffer into a global instance of a constructed type. This is a global that is mutated for the entire application. Is there a correct/documented way wherein I could decode my data into a private, local instance of the desired type, rather than mutating global state? A simple attempt involving
copy.deepcopy
seemed to work, but I don't know if that's a good idea or not. Theclone
method I saw for some types in the repository isn't present on the compiled types.The text was updated successfully, but these errors were encountered: