-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pop/enqueue/shift multiple items #1854
Comments
Good ideas. While we're at it, there are a few naming issues here:
|
How about |
My point was not to make up new names but use |
Ok, I give in and we can get rid of enqueue. I assumed we would have it if
|
I'll yield to you guys here. What about the syntax for prepending a bunch of elements? |
I think vararg |
That's ok syntactically and name-wise, but it will require some very serious work to avoid copying collections to and from the stack all the time. The problems are:
We could fix the second thing by requiring anything passed as |
That would kind of kill |
I agree, so we are left with picking out the cases we can optimize, and may have to relax the promise that a vararg object is a tuple, or maybe even indexable. I'm not totally comfortable relying on this optimization to a large extent, as the worst case is quite bad: copying a whole collection, and possibly inspecting the type of every element. That would argue for a push_all, or append/prepend. |
Sounds to me like |
+1 for getting rid of |
Python doesn't have |
My mistake. I could have sworn I looked this up in Python when we were first bikeshedding this and found that it had |
|
The python version seems pretty weird to me, but there is the issue of the type signature. Do you return an array of the popped elements or a tuple? There's also the matter of their order, of course. |
Now we have |
It would be convenient syntactically in some cases to be able to
pop
/enqueue
/shift
multiple items. It looks like the necessary low-level functionality is already there withjl_array_del_end
/jl_array_grow_beg
/jl_array_del_beg
(respectively) taking a number of elements parameter, but this isn't currently exposed.Additional methods for
pop
andshift
could be added which take a number of elements parameter. There's a subtlety withenqueue
in that the syntax should be consistent with thepush
/append!
pair.The text was updated successfully, but these errors were encountered: