Hi, we are working on changing most of our API ret...
# ksp
j
Hi, we are working on changing most of our API return type from
Collection
to
Sequence
for a better performance. This change will need your attention as
Sequence
is lazily evaluated and requires a terminal operation to make it actually compute. Here is my API change, please kindly take a look and leave comments in case of any concerns. The most important item I want to hear from you is if your use case involves some operations that is not feasible with a sequence, like indexed access operation which is only possible on a List (while you can still call
.toList()
on a sequence to do that, if this becomes a common use case, it might make more sense to just make it
List
)
👍 5
e
Most of my use-cases are trying to find a specific element so this seems like a net-positive. There's a few cases where I just want all of them though like with function args or typeParameters because I'm just trying to write out or call it.
j
yea, if your use case involves early termination this is net positive. if you use case is around iterating all elements, then this is slightly worse than a list due to decorating overhead. I think the key here is, for a specific API, if the use case of iterating all elements is common enough so that I can justify reverting it back to
List
e
If you want a general rule for this, I'd say when searching for files/class/functions then early-return is valuable. But not so much when you get into a specific type or function. Well maybe except for annotations? Since you are probably looking for a certain one.
j
what you describe sounds more like context on the use case involved rather than API itself? But I do feel what you mentioned, in that case, do you think it’s better to make all
typeParameter
s, `typeArgument`s, general
argument
s and function `parameter`s to be simply
List
e
Yep
e
I really love this idea for improving performance 👍 I would think the overhead of decoration for a sequence is negligible compared to type resolving and other operations that might be applied to the elements, so imo I would lean towards Sequence if there was ever a question between Sequence or List
1
j
We had some internal discussion, we feel it might be a common use case that for parameters and arguments, that users will want to know the size and do indexed access (like generating arguments according to parameter list, or read argument values according to a parameter list), which is feature of
List
, therefore it is better to keep them
List
. Furthermore, in our implementations, most of these arguments and parameters are just a wrapper of underlying data structure so not heavy work involved, performance wise is not very significant.
👍 3
e
That makes sense. I think the real benefit of Sequences comes when getting elements in a package, file, or class. This sounds like a good balance