Is there a guide to understanding time, space comp...
# announcements
d
Is there a guide to understanding time, space complexity for kotlin utility functions? e.g. “str”.reversed(), arr.sortedBy{ } etc.
n
no but the source is usually very readable. only problem with that is the source can change; it's not a part of the documented contract.
n
It is somewhat surprising that it's not part of the spec, IMHO
Sorts for example should guarantee worst case N log N, developers shouldn't have to guess or read source. Maybe they are constrained because they want to use JVM implementations on that platform, and they don't make that guarantee, officially
g
kotlin wants to give you what the platform already has, and remember for native/js that may be different than JVM. Those methods are there for convenience, and are in most cases pretty fast, but they're also very functionally oriented, meaning you're going to blow up your runtime performance with memory thrashing anyways
ahem, bump for kotlinx immutable collections: https://github.com/Kotlin/kotlinx.collections.immutable
n
There are in place sorts
and no guarantees are given in that case either
So, eh, I dunno about that idea, it amounts to saying its slow anyway, so who cares
But if the array is large, N log N with bad constants is probably still bearable, but N^2 probably is just not ok even with good constants
d
Thank you guys for the response.
With the utility functions making things simpler, figuring out complexity right off seems confusing.
a