Live data from Hacker News

Accidentally quadratic: When Python is faster than C++

arxiv.org

211–215 of 215 posts

Re: Accidentally quadratic: When Python is faster than C++

#211

Earlier quoted context omitted.

They've been in the language for about a decade now, and before that we had the tr1 hash_map classes that were available in most environments.

C++: the language that's been around for 40 years and is completely new!

Actually, C++ has barely been around at all. It is only with C++20, IIANM, that they key features Bjarne Stroustrup wanted to imbue it with are in place (IIRC; see his "Design & Evolution of C++" book from 1994). Some might even argue that the language C++ _should_ be is not even all here; it's still gradually arriving.

Re: Accidentally quadratic: When Python is faster than C++

#212

Earlier quoted context omitted.

1. People often use set instead of unordered_set (and same for map) despite not needing order. This slows things down. 2. The C++ standard library's maps and sets are known to be rather slow. See, for example: https://stackoverflow.com/q/42588264/1593077 when you have string values, it's even worse, as you describe. But it's not clear that an overly-clever implementation, which caches numeric ranks of strings etc., i…

Why is the default set implementation ordered in the first place? The formal data structure is unordered, which probably informs people's assumptions about its performance characteristics. Should it not be "set" and "ordered_set"?

It's a mis-feature. And since C++ is very committed to backwards compatibility, they didn't change it later on.

If/when `std2::` happens, this is one of the things I assume would change.

Re: Accidentally quadratic: When Python is faster than C++

#213

Earlier quoted context omitted.

You can literally emit runtime assembly in C in any C toolchain, what are you on about?

How do you dynamically generate machine code without linking something like LLVM?

same way you would with llvm, you can map executable memory without llvm and execute it.

Re: Accidentally quadratic: When Python is faster than C++

#214

Earlier quoted context omitted.

Goto considered harmful is from 1968, so yes.

"goto considered harmful" was at least not wrong. It didn't say who considered it harmful, but at least it was still presented as an opinion. This title states "Python is Faster Than C++", which neither implies that this is just an opinion, nor that it isn't an absolute statement. You have to figure out yourself that it's probably hyperbolic and just referring to special cases.

Not "Python is Faster Than C++" but "When Python is Faster Than C++"

Re: Accidentally quadratic: When Python is faster than C++

#215

Earlier quoted context omitted.

More like "well tuned JS will be nearly as fast as poorly tuned C code"...

True. But if I’m given the choice, I’d usually rather well written javascript than badly written C. And there’s a lot more decent JS programmers out there than decent C programmers.

Fair. I'd rather neither, and take Python, or even (God forbid) PHP. LOL
Post reply on HN