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
The reason for the "dimension_coordinates" alias being an attribute rather than method is that it was expected that it would often be followed by more options:
It turns out that the code for accessing constructs is very slow, and must be improved.
A key part of this improvement relies on being able to work with python dictionaries rather than dictionary-like Constructs objects.
To facilitate this, whilst retaining the intuitive nature of the API the least intrusive change is to make what were attributes properties: i.e. f.dimension_coordinates becomes f.dimension_coordinates(). This then allows keyword parameters that can change the behaviour when speed is an issue.
Code breaking
This change will break any code that uses bare construct access attributes:
>>># These won't work any more>>>f.auxiliary_coordinates>>>f.coordinate_references>>>f.coordinates>>>f.cell_measures>>>f.dimension_coordinates>>>f.domain_ancillaries>>>f.domain_axes>>>f.cell_methods>>>f.field_ancillaries
>>># These will work as before>>>f.auxiliary_coordinates()
>>>f.coordinate_references()
>>>f.coordinates()
>>>f.cell_measures()
>>>f.dimension_coordinates()
>>>f.domain_ancillaries()
>>>f.domain_axes()
>>>f.cell_methods()
>>>f.field_ancillaries()
>>># These will also work as before>>>f.auxiliary_coordinates(x)
>>>f.coordinate_references(x)
>>>f.coordinates(x)
>>>f.cell_measures(x)
>>>f.dimension_coordinates(x)
>>>f.domain_ancillaries(x)
>>>f.domain_axes(x)
>>>f.cell_methods(x)
>>>f.field_ancillaries(x)
This is the only backwards incompatible change to the API. All other changes will not break existing code.
With the new API, reading a file is, in one reproducible test, ~3 times faster:
Note that much of the improvement comes from unrelated changes (such as removing unnecessary __repr__ calls and unnecessary deep copies).
See NCAS-CMS/cfdm#130 for further details. In particular, the cfdm version of the above timing test gives a ~10 times speed up - the reasons for the lesser improvement in cf-python will need investigating
Edit: The less speed-up is understandable and due to extra checks being carried out in, e.g., set_construct. This is not to say that things can't be sped up more, but that is for another issue
PR to follow ...
The text was updated successfully, but these errors were encountered:
Current situation
Access to named constructs is currently either by the "filter_by_*"
Constructs
methods, or by Field attributes:The reason for the "dimension_coordinates" alias being an attribute rather than method is that it was expected that it would often be followed by more options:
This is fine, but comes with the slight confusion that the result of the attribute is a callable
Constructs
instance, which obfuscates the help:Performance
It turns out that the code for accessing constructs is very slow, and must be improved.
A key part of this improvement relies on being able to work with python dictionaries rather than dictionary-like
Constructs
objects.To facilitate this, whilst retaining the intuitive nature of the API the least intrusive change is to make what were attributes properties: i.e.
f.dimension_coordinate
s becomesf.dimension_coordinates()
. This then allows keyword parameters that can change the behaviour when speed is an issue.Code breaking
This change will break any code that uses bare construct access attributes:
This is the only backwards incompatible change to the API. All other changes will not break existing code.
With the new API, reading a file is, in one reproducible test, ~3 times faster:
Note that much of the improvement comes from unrelated changes (such as removing unnecessary
__repr__
calls and unnecessary deep copies).See NCAS-CMS/cfdm#130 for further details. In particular, the cfdm version of the above timing test gives a ~10 times speed up - the reasons for the lesser improvement in cf-python will need investigating
Edit: The less speed-up is understandable and due to extra checks being carried out in, e.g.,
set_construct
. This is not to say that things can't be sped up more, but that is for another issuePR to follow ...
The text was updated successfully, but these errors were encountered: