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

Merged
merged 1 commit into from
Nov 26, 2024
Merged

Improve speed of TRCReader #1893

merged 1 commit into from
Nov 26, 2024

Conversation

lebuni
Copy link
Contributor

@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
Contributor 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.
Copy link
Collaborator

@zariiii9003 zariiii9003 left a comment

Choose a reason for hiding this comment

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

Looks good, thank you

@zariiii9003 zariiii9003 merged commit 226e040 into hardbyte:main Nov 26, 2024
33 checks passed
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