diff --git a/README.md b/README.md index 4ec5064..1999681 100644 --- a/README.md +++ b/README.md @@ -1572,7 +1572,7 @@ Memory View Deque ----- -**Thread-safe list with efficient appends and pops from either side. Pronounced "deck".** +**A thread-safe list with efficient appends and pops from either side. Pronounced "deck".** ```python from collections import deque @@ -1589,6 +1589,16 @@ from collections import deque .rotate(n=1) # Rotates elements to the right. ``` +```python +>>> a = deque([1, 2, 3], maxlen=3) +>>> a.append(4) +[2, 3, 4] +>>> a.appendleft(5) +[5, 2, 3] +>>> a.insert(6, 1) +IndexError: deque already at its maximum size +``` + Threading --------- diff --git a/index.html b/index.html index fd7e659..f82e628 100644 --- a/index.html +++ b/index.html @@ -1362,7 +1362,7 @@ db.commit() <memoryview>.release()

#Deque

-

Thread-safe list with efficient appends and pops from either side. Pronounced "deck".

+

A thread-safe list with efficient appends and pops from either side. Pronounced "deck".

from collections import deque
 <deque> = deque(<collection>, maxlen=None)
 
@@ -1372,6 +1372,14 @@ db.commit()
<deque>.extendleft(<collection>)  # Collection gets reversed.
 <deque>.rotate(n=1)               # Rotates elements to the right.
 
+
>>> a = deque([1, 2, 3], maxlen=3)
+>>> a.append(4)
+[2, 3, 4]
+>>> a.appendleft(5)
+[5, 2, 3]
+>>> a.insert(6, 1)
+IndexError: deque already at its maximum size
+

#Threading

from threading import Thread, RLock