Hacker News new | ask | show | jobs
by d0mine 4863 days ago

    atoi(strchr(s, '-') + 1)
What does this do? Finds the first instance of a -, and converts the remainder of a string to an int. 0 allocations, 0 copies. Doing this with 0 copies is pretty much impossible in Python, and probably in ruby and Javascript too. </quote>

The copying could be avoided in non-idiomatic Python:

    int(buffer(s, s.find("-") + 1))
1 comments

   +s.substr(s.indexOf('-') + 1)