diff options
Diffstat (limited to 'Doc/whatsnew/whatsnew24.tex')
-rw-r--r-- | Doc/whatsnew/whatsnew24.tex | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/Doc/whatsnew/whatsnew24.tex b/Doc/whatsnew/whatsnew24.tex index f435b87..ed4a57f 100644 --- a/Doc/whatsnew/whatsnew24.tex +++ b/Doc/whatsnew/whatsnew24.tex @@ -322,6 +322,31 @@ euc-jisx0213, iso-2022-jp, iso-2022-jp-1, iso-2022-jp-2, \item Korean: cp949, euc-kr, johab, iso-2022-kr \end{itemize} +\item There is a new \module{collections} module which currently offers + just one new datatype, \class{deque}, which offers high-performance, + thread-safe, memory friendly appends and pops on either side of the + deque resulting in efficient stacks and queues: + +\begin{verbatim} +>>> from collections import deque +>>> d = deque('ghi') # make a new deque with three items +>>> d.append('j') # add a new entry to the right side +>>> d.appendleft('f') # add a new entry to the left side +>>> d # show the representation of the deque +deque(['f', 'g', 'h', 'i', 'j']) +>>> d.pop() # return and remove the rightmost item +'j' +>>> d.popleft() # return and remove the leftmost item +'f' +>>> list(d) # list the contents of the deque +['g', 'h', 'i'] +>>> 'h' in d # search the deque +True +\end{verbatim} + +Several modules now take advantage of \class{collections.deque()} for +improved performance: \module{Queue}, \module{mutex}, \module{shlex} +\module{threading}, and \module{pydoc}. \item The \module{heapq} module has been converted to C. The resulting ten-fold improvement in speed makes the module suitable for handling |