
Python is widely celebrated for its simplicity and readability, making it a favorite among beginners and seasoned developers alike. However, it's a...
For further actions, you may consider blocking this person and/or reporting abuse
Write on medium too!
Thanks Anmol Baranwal Subscriber!
I’ve been considering it. I would love to start writing on Medium too soon. Appreciate the encouragement
Regards,
Ram
Instead of a list of options I would preferred to see more explanation why to use one or the other and also more context.
A list comprehension is faster than the
map
function when not using a lambda. So if you want speed the map example should beFor 4 and 16, the fix is use the right data structure.
Avoid global variables is not only a speed fix, it makes the code more maintainable.
9 and 13 are the same thing, so there are 19 different things.
Between
defaultdict
andCounter
, the latter will be faster as the first is more generic.Only use
@staticmethod
and@classmethod
when it is appropriate. Don't use them just to avoid class instantiation.Hi david duymelinck
Thanks so much for the thoughtful feedback, You're absolutely right. I appreciate you pointing out where more explanation would add value. Also great catch on the overlap between points 9 and 13. l will consolidate that. Feedback like yours really helps improve the quality.
Thanks & Regards,
Ram
Thanks for this article! 🔥
Hi davinceleecode
Thanks for reading. Glad you liked it!
Regards,
Ram
Great article. I would have appreciated a little more explanation (such as the data structures and algorithms behind certain python methods) on why you use a specific syntax rather than another.
Hi Teddy Assih,
Thank you for the feedback. I will update the post with explanations.
Regards,
Ram
been using python for a bit and some of these little changes really do help, keeps me going back to refactor old code all the time
Thank you for the acknowledgment Nevo David 😊👍
Thank you so much for this! ✨
Hi Anita Olsen,
You’re very welcome! I’m glad you found it helpful. 😊👍
Regards,
Ram
pretty cool rundown tbh, i always forget about stuff like lru_cache till i see it used - you ever feel like most speed problems only show up when something actually breaks?
Hi Nathan Tarbert,
Thanks for the comment. I’ve never really faced or noticed that myself. Most of the time, things just run fine unless I’m specifically benchmarking or digging into optimizations.
Regards,
Ram
absolutely love little speed tricks like these honestly makes coding way less annoying over time
Hi Nathan Tarbert
Good to hear that. Refactoring old code with small optimizations can really make a big difference over time. I'm glad the post sparked that motivation!
Thanks & Regards,
Ram
Good!
Thank you RankmyAl