Let’s say I have a string of 10 characters “abcdefghij” and I want to split it by every 3rd character. The output would be a list “abc”,”def”,”ghi”,”j”. But the issue now comes when im dealing with a string that can contain up to 2,591,999 characters that i need to split into chunks each containing of at most 117,760 character. I need the fastest way to do this within Snap!
I think the main issue is how much we are dealing with lists. Is there any way to create substrings without lists
Lists are much slower because itterating. At least in my mind. I didnt go through source code
They’re only slow if you’re dealing with multiple extremely large lists. For most uses, this is perfectly fine.
But for edge case is there a way to speed it up
If you run into an edge case, then you can figure it out
my 1st attemp was the same as ego-lay_atman-bay: about 5 seconds for 2.8 million chars i think it was the best way
i tested another way, but it isin’t efficient at all (about 30 seconds)…
![]()
Ok
don’t use this people use @mark4sisb 's!
kinda similar to @ego-lay_atman-bay if you think about it so no surprise that it is about the same speed. POSSIBLY faster but idk (avi_shor you may want to do some testing to see what works for you.)
I found that your version is roughly 0.2 ms faster, and my version (see below; modified from yours) is roughly 0.04 ms faster than yours (regardless of whether the map is compiled, although with larger strings this may make a difference).
I had compiled it but it crashed snap with large numbers.



