Skip to content

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.

can/io/trc.py Outdated
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

2 participants