Follow

So I did some speedtests for my image formats.
Raw PNG as bytestrings is definitely the fastest by far, but takes a lot of space.
Then there's various ways of decoding my run-length-encoded strings, by keeping the character counter as an integer or as a string. (more explanation in replied toot with cw)

tech explanation of replied post 

The RLE string looks something like this: "70b5a3b"
the decoding function then goes through the string, character by character. If it's a number, it needs to increment it's count, if it sees a letter, it will expand it to current count times that letter. I can either directly draw current count pixels, or store the result as an expanded string with lots of a's and b's, and draw it after the decode.

The RLE implementation I found online keeps the count as a string like this:
count = ''
if current is a number:
count += current number (concatinate as a string)
else:
parse count as an integer

I did a more efficient implementation with just arithmetic, because strings are expensive.
if current is a number:
count = count*10 + current number

as seen from the speedtest, this is quite a bit faster

Sign in to participate in the conversation
Pixietown

Small server part of the pixie.town infrastructure. Registration is closed.