Skip to content

Commit 2ade580

Browse files
committed
Deque
1 parent e48a865 commit 2ade580

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,6 +1992,9 @@ Deque
19921992
```python
19931993
from collections import deque
19941994
<deque> = deque(<collection>, maxlen=None)
1995+
```
1996+
1997+
```python
19951998
<deque>.appendleft(<el>) # Opposite element is dropped if full.
19961999
<el> = <deque>.popleft() # Raises IndexError if empty.
19972000
<deque>.extendleft(<collection>) # Collection gets reversed.
@@ -2651,9 +2654,9 @@ from PIL import Image
26512654
```
26522655

26532656
```bash
2654-
<2d_array> = np.array(<Image>) # Generates NumPy array from greyscale image.
2655-
<3d_array> = np.array(<Image>) # Generates NumPy array from color image.
2656-
<Image> = Image.fromarray(<array>) # Generates image from NumPy array.
2657+
<2d_array> = np.array(<Image>) # Converts greyscale image to NumPy array.
2658+
<3d_array> = np.array(<Image>) # Converts color image to NumPy array.
2659+
<Image> = Image.fromarray(<array>) # Converts NumPy array to Image.
26572660
```
26582661

26592662
### Modes

index.html

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1761,13 +1761,14 @@
17611761

17621762
<div><h2 id="deque"><a href="#deque" name="deque">#</a>Deque</h2><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
17631763
&lt;deque&gt; = deque(&lt;collection&gt;, maxlen=<span class="hljs-keyword">None</span>)
1764-
&lt;deque&gt;.appendleft(&lt;el&gt;) <span class="hljs-comment"># Opposite element is dropped if full.</span>
1765-
&lt;el&gt; = &lt;deque&gt;.popleft() <span class="hljs-comment"># Raises IndexError if empty.</span>
1766-
&lt;deque&gt;.extendleft(&lt;collection&gt;) <span class="hljs-comment"># Collection gets reversed.</span>
1767-
&lt;deque&gt;.rotate(n=<span class="hljs-number">1</span>) <span class="hljs-comment"># Rotates elements to the right.</span>
17681764
</code></pre></div>
17691765

17701766

1767+
<pre><code class="python language-python hljs">&lt;deque&gt;.appendleft(&lt;el&gt;) <span class="hljs-comment"># Opposite element is dropped if full.</span>
1768+
&lt;el&gt; = &lt;deque&gt;.popleft() <span class="hljs-comment"># Raises IndexError if empty.</span>
1769+
&lt;deque&gt;.extendleft(&lt;collection&gt;) <span class="hljs-comment"># Collection gets reversed.</span>
1770+
&lt;deque&gt;.rotate(n=<span class="hljs-number">1</span>) <span class="hljs-comment"># Rotates elements to the right.</span>
1771+
</code></pre>
17711772
<div><h2 id="threading"><a href="#threading" name="threading">#</a>Threading</h2><ul>
17721773
<li><strong>CPython interpreter can only run a single thread at a time.</strong></li>
17731774
<li><strong>That is why using multiple threads won't result in a faster execution, unless there is an I/O operation in the thread.</strong></li>
@@ -2259,9 +2260,9 @@
22592260
&lt;Image&gt;.putdata(&lt;list/ImagingCore&gt;) <span class="hljs-comment"># Writes a sequence of pixels.</span>
22602261
&lt;Image&gt;.paste(&lt;Image&gt;, (x, y)) <span class="hljs-comment"># Writes an image to image.</span>
22612262
</code></pre>
2262-
<pre><code class="bash language-bash hljs">&lt;2d_array&gt; = np.array(&lt;Image&gt;) <span class="hljs-comment"># Generates NumPy array from greyscale image.</span>
2263-
&lt;3d_array&gt; = np.array(&lt;Image&gt;) <span class="hljs-comment"># Generates NumPy array from color image.</span>
2264-
&lt;Image&gt; = Image.fromarray(&lt;array&gt;) <span class="hljs-comment"># Generates image from NumPy array.</span>
2263+
<pre><code class="bash language-bash hljs">&lt;2d_array&gt; = np.array(&lt;Image&gt;) <span class="hljs-comment"># Converts greyscale image to NumPy array.</span>
2264+
&lt;3d_array&gt; = np.array(&lt;Image&gt;) <span class="hljs-comment"># Converts color image to NumPy array.</span>
2265+
&lt;Image&gt; = Image.fromarray(&lt;array&gt;) <span class="hljs-comment"># Converts NumPy array to Image.</span>
22652266
</code></pre>
22662267
<div><h3 id="modes-1">Modes</h3><ul>
22672268
<li><strong><code class="python hljs"><span class="hljs-string">'1'</span></code> - 1-bit pixels, black and white, stored with one pixel per byte.</strong></li>

0 commit comments

Comments
 (0)