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

Improve speed of TRCReader #1893

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Improve speed of TRCReader #1893

wants to merge 1 commit into from

Conversation

lebuni
Copy link

@lebuni lebuni commented Nov 10, 2024

Optimized TRCReader for speed, mainly for TRC files v2.x. According to cProfile it's double as fast now.

@lebuni lebuni force-pushed the patch-1 branch 3 times, most recently from ead5baa to 6ed6578 Compare November 12, 2024 19:49
can/io/trc.py Outdated
@@ -58,13 +55,16 @@ def __init__(
"""
super().__init__(file, mode="r")
self.file_version = TRCFileVersion.UNKNOWN
self.start_time: Optional[datetime] = None
self.start_time: float = 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This attribute is public, so changing the type could break user code. I'd suggest creating a private float attribute _timestamp and a property timestamp, that returns a datetime instance like before.

Otherwise this looks good to me.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! Changed it

Rewrote some lines in the TRCReader to optimize for speed, mainly for TRC files v2.x. According to cProfile it's double as fast now.
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

Successfully merging this pull request may close these issues.

2 participants