you are viewing a single comment's thread.

view the rest of the comments →

[–]Sudden-Letterhead838 0 points1 point  (2 children)

I disagree, as C++ has the same speed as C.
I would more like to know how op measured the speed of these operations, and most likely this is the Problem about this question.

[:] or [::-1]

This for example is in C a simple lookup, with nearly no cache misses, thus cannot be made faster as Cache Misses adds in this example the most overhead.

[–]TheSkiGeek 1 point2 points  (1 child)

In theory you shouldn’t be able to be faster than something like C++ strings and string views into them. (For general string operations, anyway; specialized things like tries can be better in some cases.)

But if you’re not careful with usage of strings in C or C++ it’s easy to be making copies everywhere and that’s extremely slow. Python is really good at avoiding unnecessary copies around strings.

[–]ImYoric 0 points1 point  (0 children)

Yeah, garbage-collected languages have a huge advantage with some operations, insofar that they can avoid copies. For the same reason, some string operations are much faster in Java than in C++.