News for hackers. Stuff that matters.
Re:Why Python is Slow: Looking Under the Hood by nly on Friday May 09, 2014 @04:33PM (#7723127)
> You can express in Python some things in a single line, where you need hundreds of lines in C++ or other languages.

citation needed.

Re:Why Python is Slow: Looking Under the Hood by Borogove on Friday May 09, 2014 @07:51PM (#7723904)
Example: x = {'foo':34,'bar':[1,2,3],'baz':'quux'}

The headers alone for STL maps are hundreds of LOC.

Re:Why Python is Slow: Looking Under the Hood by zmmmmm on Friday May 09, 2014 @10:06PM (#7724209)
Counting headers is rather unfair.

C++11:

map<int, char> x = {{1, 'a'}, {3, 'b'}, {5, 'c'}, {7, 'd'}};

Any not-ancient C++ using boost Assign:

map<int, char> x = map_list_of (1, 'a') (3, 'b') (5, 'c') (7, 'd');

Shamelessly stolen from here:

http://stackoverflow.com/questions/138600/initializing-a-sta...

Re:Why Python is Slow: Looking Under the Hood by nly on Saturday May 10, 2014 @07:04AM (#7725053)
That's tricky, because C++ is statically typed and you've selected a varying value type, but here's the closest thing in real terms.

    #include <map>
    #include <vector>
    #include <string>
    #include <boost/any.hpp>
    using boost::any;
    using std::map;
    using std::string;
    using std::vector;

    int main() {
        map<string,any> x = {{"foo", 34}, {"bar", vector<int>{1,2,3}}, {"bar", "quux"}};
    }
Syntax overhead amortizes to constant factor ;)
Re:Why Python is Slow: Looking Under the Hood by GFK_of_xmaspast on Friday May 09, 2014 @08:59PM (#7724076)
I agree with the upstream comment about expressiveness, but this isn't a fair example.
Re:Why Python is Slow: Looking Under the Hood by PythonicAlpha on Friday May 09, 2014 @05:32PM (#7723362)
I have none, it is my personal experience, since I programmed in C++ (and other languages) before. So cite me, if necessary.