r/ProgrammerHumor • • Aug 26 '20

Python goes brrrr

Post image
59.2k Upvotes

789 comments sorted by

View all comments

46

u/[deleted] Aug 26 '20

Operator overloading goes brrrrrr

15

u/[deleted] Aug 26 '20

As a C++ fan, I came for this comment

1

u/MultipleMonomials Aug 26 '20

I used this on a previous project (that involved a lot of ASCII graphics)

std::string operator*(std::string const & string, std::string::size_type times)
{	
    std::string sum;
    for(size_t count = 0; count < times; ++count)	
    {
        sum.append(string);
    }
    return sum;
}

Though looking at it, maybe stringstream would have been faster, hmm.