A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2003-October/039460.html below:

[Python-Dev] PyList API missing PyList_Pop() and PyList_Delete

[Python-Dev] PyList API missing PyList_Pop() and PyList_Delete [Python-Dev] PyList API missing PyList_Pop() and PyList_DeleteRaymond Hettinger python at rcn.com
Fri Oct 24 15:01:09 EDT 2003
> -----Original Message-----
[Raymond]
> > The bummer is that this call is effectively used in a loop and runs
once
> > for every data element in an iterable.  Something like pop() has
such a
> > tiny granularity that its runtime is overwhelmed by the lookup time
to
> > call it this way.  For this reason, I think PyList_Pop() warrants
> > inclusion in the API much more than low granularity methods like
> > PyList_Reverse() or PyList_Sort().
> 
> But it's easy to simulate a pop, writing the C equivalent of
> 
>     x = lst[len(lst)-1]
>     del lst[len(lst)-1 : len(lst)]

 . . .
>     PyList_SetSlice(lst, n-1, n, NULL);

There's the new piece of information.  I didn't know that the final
argument could be NULL and creating/destroying and empty list for the
arg was unpleasant.  I'll add that info to the API docs.


> I see no need to add this to the public API just yet (it would have to
> be more flexible to allow lst.pop(n), do more arg checks, etc.).


Yes.  See if more requestors come along.

Surely, I was not the first to want to use PyLists as append/pop stacks
for PyObjects.

Thanks,


Raymond


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4