Ridgure / TwitchBot

This is an irc bot written in python by Ridgure for Ridgure
https://www.twitch.tv/ridgure
MIT License
5 stars 4 forks source link

Overcomplicating things? #13

Open kbigliar opened 5 years ago

kbigliar commented 5 years ago

https://github.com/Ridgure/TwitchBot/blob/28e2a8d164e46c6eaf3cc46a9761fee3e0ea8a25/bot.py#L207-L227 and https://github.com/Ridgure/TwitchBot/blob/28e2a8d164e46c6eaf3cc46a9761fee3e0ea8a25/bot.py#L234-L237

Why not use currentDateTime = datetime.datetime.now() ?

kbigliar commented 5 years ago

Better yet, declare currentDateTime outside the for loop on line 182.

kbigliar commented 5 years ago

Timing code seen here: https://repl.it/repls/BetterWideCopyright Destructing and rebuilding a datetime runs on average about 4 times as slow as just using a datetime.datetime.now(). Additionally, as you don't care for the microsecond differences in the time, building the datetime for each follower currently increases the overhead about a thousandfold and linearly takes longer the more followers you get.