|
|
@ -1362,7 +1362,7 @@ db.commit() |
|
|
|
<memoryview>.release() |
|
|
|
</code></pre> |
|
|
|
<h2 id="deque"><a href="#deque" name="deque">#</a>Deque</h2> |
|
|
|
<p><strong>Thread-safe list with efficient appends and pops from either side. Pronounced "deck".</strong></p> |
|
|
|
<p><strong>A thread-safe list with efficient appends and pops from either side. Pronounced "deck".</strong></p> |
|
|
|
<pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> collections <span class="hljs-keyword">import</span> deque |
|
|
|
<deque> = deque(<collection>, maxlen=<span class="hljs-keyword">None</span>) |
|
|
|
</code></pre> |
|
|
@ -1372,6 +1372,14 @@ db.commit() |
|
|
|
<pre><code class="python language-python hljs"><deque>.extendleft(<collection>) <span class="hljs-comment"># Collection gets reversed.</span> |
|
|
|
<deque>.rotate(n=<span class="hljs-number">1</span>) <span class="hljs-comment"># Rotates elements to the right.</span> |
|
|
|
</code></pre> |
|
|
|
<pre><code class="python language-python hljs"><span class="hljs-meta">>>> </span>a = deque([<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>], maxlen=<span class="hljs-number">3</span>) |
|
|
|
<span class="hljs-meta">>>> </span>a.append(<span class="hljs-number">4</span>) |
|
|
|
[<span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>] |
|
|
|
<span class="hljs-meta">>>> </span>a.appendleft(<span class="hljs-number">5</span>) |
|
|
|
[<span class="hljs-number">5</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>] |
|
|
|
<span class="hljs-meta">>>> </span>a.insert(<span class="hljs-number">6</span>, <span class="hljs-number">1</span>) |
|
|
|
IndexError: deque already at its maximum size |
|
|
|
</code></pre> |
|
|
|
<h2 id="threading"><a href="#threading" name="threading">#</a>Threading</h2> |
|
|
|
<pre><code class="python language-python hljs"><span class="hljs-keyword">from</span> threading <span class="hljs-keyword">import</span> Thread, RLock |
|
|
|
</code></pre> |
|
|
|