21.11.17 11:27, Kirill Balunov пише:
Your implementation iterates seq multiple times. But iterable
unpacking syntax works with an arbitrary iterable, and iterates it
only once.
Oh sorry, I know that my implementation iterates seq multiple times, I
only provide this to show the idea. It can be much optimized at C level.
I just want to understand if it's worth the time and effort.
You can implement the first case, but for other cases you will need a
storage for saving intermediate items. And using a list is a good option.
And you already have mentioned a question about mutable sequence.
If these conditions and restrictions suit you, you can use your
good_star_exp() in your code or share it with others. But the
semantic of iterable unpacking can't be changed.
And how do you look at something like this (deferred star evaluation)?:
a, ?*b, c, d = something_iterable
This will be not different from
a, *b, c, d = something_iterable
b = iter(b)
There is nothing deferred here.
The only possible benefit can be in the case
a, b, ?*c = something_iterable
But I have doubts that this special case deserves introducing a new syntax.
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/