Skip to content

RecordBase.__init__ slows down #55

@xmedeko

Description

@xmedeko

fitparse uses many many objects and many of them are of RecordBase, The RecordBase.__init__ is a bit slow. E.g. I've tried to optimize FieldData.__init__:

     def __init__(self, field_def = None, field= None, parent_field= None, value= None, raw_value= None, units= None):
        self.field_def = field_def
        self.field = field
        self.parent_field = parent_field
        self.value = value
        self.raw_value = raw_value
        self.units = units
        ...

And parsing of event_timestamp.fit has sped up by 0.8 sec. Generally, the getattr, hasattr and setattr slows down the process when used so extensively.

I may create PR to change all RecordBase and descendants init. But there's a remark in the records.py:

    # TODO: switch back to namedtuple, and don't use default arguments as None
    #       and see if that gives us any performance improvements

Note: Also, the processor.py uses getattr, extensivelly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions