Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RecordBase.__init__ slows down #55

Open
xmedeko opened this issue Mar 6, 2018 · 1 comment
Open

RecordBase.__init__ slows down #55

xmedeko opened this issue Mar 6, 2018 · 1 comment

Comments

@xmedeko
Copy link
Contributor

xmedeko commented Mar 6, 2018

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.

@dtcooper
Copy link
Owner

dtcooper commented Mar 6, 2018

Thanks for noting the comment and letting us know. Of course a PR would be welcome! :)

xmedeko added a commit to xmedeko/python-fitparse that referenced this issue Mar 7, 2018
xmedeko added a commit to xmedeko/python-fitparse that referenced this issue Mar 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants