First time I've hit the string concatenation issue in Ruby. This wastes ~1g of memory for a 600k character input:pic.twitter.com/8v1tz9Tdtr
When you tweet with a location, Twitter stores that location. You can switch location on/off before each Tweet and always have the option to delete your location history. Learn more
@charliesome @m1sp uhhhh even if it didn't, you should only have two copies of each string live at any given time, htf does that get to 1g
@charliesome @m1sp whoops
well then this isn't an issue in CPython because it's mostly refcounted 8)
@charliesome @m1sp but string building by concatenation is O(nm) so you shouldn't be doing it anyway tsk tsk
Array#join is faster than either form of concatenation, as @eevee points outhttp://stackoverflow.com/a/23555375/1983739 …
@m1sp that's a bad benchmark, the Array#join case is only faster because it runs less Ruby code and allocates fewer objects
@m1sp Array#join uses a loop and String#<< internally (although it calls the C function for #<< directly rather than making a method call)
@AndreaFaulds @charliesome and there is no such branching to be found in the Ruby equivalent, yep ^^ https://github.com/ruby/ruby/blob/trunk/string.c#L1444 …
@m1sp @charliesome In CPython not all strings are expandable that way. In practice it's a chancy optimization and you shouldn't count on it.
@charliesome @m1sp A 2005 view of the CPython 2.4 situation is http://utcc.utoronto.ca/~cks/space/blog/python/ExaminingStringConcatOpt … . I'm sure there's been changes since for eg Unicode.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.