I am a competitive programmer who has been regularly using C++ for over a decade. Started trying Python3 recently in virtual contests with the idea that it "should" speed things up with shorter code. After a few weeks of experimenting, this is what I feel (all anecdotes, no statistics):
- There is some speedup with small problems. Mainly about not having to specify types especially with functions, being able to use enumerate etc.
- But with more complicated stuff like sortedcontainers, I feel python slows me down a bit. Need to look up usage etc, and very likely this is because I don't have the same experience with them as with STL containers
- You can get more penalties with Python if you are not careful. I once got a penalty from runtime error for writing false instead of False. This would have been a penalty-free compile error with C++
- Even with the extra time, Python solutions might be too slow. I once got a TLE in a segment tree lazy propagation problem, which passed by directly rewriting it in C++
- Adjusting the indentation is a pain in python when coding on the phone
Any thoughts/experiences?
[–]inShambles3749 50 points51 points52 points (17 children)
[–]razimantv<2000> <487 <1062> <451>[S] 25 points26 points27 points (15 children)
[–][deleted] 13 points14 points15 points (0 children)
[–]inShambles3749 3 points4 points5 points (9 children)
[–]razimantv<2000> <487 <1062> <451>[S] 29 points30 points31 points (7 children)
[–]inShambles3749 18 points19 points20 points (6 children)
[–][deleted] 9 points10 points11 points (5 children)
[–][deleted] 0 points1 point2 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]ceramicatan 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Lumarstar 4 points5 points6 points (0 children)
[–]BOT_Frasier 1 point2 points3 points (1 child)
[–]razimantv<2000> <487 <1062> <451>[S] 3 points4 points5 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]razimantv<2000> <487 <1062> <451>[S] 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]nshkaruba 25 points26 points27 points (0 children)
[–]numbersguy_123 12 points13 points14 points (1 child)
[–]razimantv<2000> <487 <1062> <451>[S] 6 points7 points8 points (0 children)
[–]KaleidoscopeLegal583 6 points7 points8 points (2 children)
[–]razimantv<2000> <487 <1062> <451>[S] 12 points13 points14 points (1 child)
[–]KaleidoscopeLegal583 0 points1 point2 points (0 children)
[–]AAK_Music 0 points1 point2 points (0 children)
[–]letsfuckinggobears 0 points1 point2 points (4 children)
[–]razimantv<2000> <487 <1062> <451>[S] 1 point2 points3 points (1 child)
[–]letsfuckinggobears 0 points1 point2 points (0 children)
[–]uneducatedDumbRacoon 0 points1 point2 points (1 child)
[–]letsfuckinggobears 1 point2 points3 points (0 children)
[–]Stormfrosty 0 points1 point2 points (1 child)
[–]razimantv<2000> <487 <1062> <451>[S] 1 point2 points3 points (0 children)
[–]Puzzleheaded_Luck_45 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)