Ryex, I updated the Ruby scripts for these methods (_dump, _load, _arc_dump, _arc_load) which turns out to have been a major optimization for Ruby. I noticed that you implemented the Python versions using the same way the Ruby versions used to be implemented. I just wanted to point that out since it would significantly speed up table dumping/loading if you packed the whole data right away with a string instead of doing it for each int and then concatenating with the result string. I noticed that concatenating is a very CPU consuming operation that requires more CPU time the longer the first string is. As I said, I'm just pointing this out as you might wanna optimize this for Python.
you know... that actually makes a whole lot of sense that it would work like that. will do.
Alright, have fun. xD
You can just take my Ruby code and port it. I think that the * operator works for Pythong strings the same way it works for Ruby strings.
/me does a quick command line test to see if that's the case
strings are still treated as sequences like lists an tuples so it should
That's true, but there is a significant difference. A Ruby string is a C-array that has always a perfect fitting size while a Ruby array allocates more memory than it needs. When the amount is exceeded, more memory is allocated in an array (yet again, more than is required so not every push command requires memory reallocation) while during string concatenation the string memory has to be reallocated every time and this is very time consuming. I noticed this performance issue when I was working on Bitmap2Code a long time ago. It's several times faster to push all strings parts into an array and just use join('') in the end to put the whole string together.
I think it doubles the amount of current allocated memory every time it needs to resize. 2 -> 4 -> 8 -> 16 -> 32 ,etc, ect.
ok, I rewrote them the way you did. yet again not tested so...
The way it works in Java is that it adds 1, then doubles the current capacity. I am not sure if that is how it is done in Ruby when it exceeds the capacity.
Then again, this is for a StringBuffer class, which is separate from a regular string. Just throwing that out there.
Most languages double the capacity. It's an old trick to avoid lots of resizing.
I don't think that there is a StringBuffer/StringBuilder class in Ruby.