* **Aware `<a>` time and datetime objects have defined timezone, while naive `<n>` don't.**
* **If object is naive, it is presumed to be in the system's timezone.**
* **Aware `<a>` time and datetime objects have defined timezone, while naive `<n>` don't. If object is naive, it is presumed to be in the system's timezone!**
* **`'fold=1'` means the second pass in case of time jumping back for one hour.**
* **`'fold=1'` means the second pass in case of time jumping back for one hour.**
* **Timedelta normalizes arguments to ±days, seconds (<86400)andmicroseconds(<1M).**
* **Timedelta normalizes arguments to ±days, seconds (<86400)andmicroseconds(<1M).**
* **Use `'<D/DT>.weekday()'` to get the day of the week as an int, with Monday being 0.**
* **Use `'<D/DT>.weekday()'` to get the day of the week as an int, with Monday being 0.**
**List that can only hold numbers of a predefined type. Available types and their minimum sizes in bytes are listed above. Sizes and byte order are always determined by the system, however bytes of each element can be swapped with byteswap() method.**
**List that can only hold numbers of a predefined type. Available types and their minimum sizes in bytes are listed above. Type sizes and byte order are always determined by the system, however bytes of each element can be swapped with byteswap() method.**
```python
```python
from array import array
from array import array
@ -2090,10 +2089,9 @@ from collections import deque
Threading
Threading
---------
---------
* **CPython interpreter can only run a single thread at a time.**
* **That is why using multiple threads won't result in a faster execution, unless at least one of the threads contains an I/O operation.**
* **CPython interpreter can only run a single thread at a time. Using multiple threads won't result in a faster execution, unless at least one of the threads contains an I/O operation.**
```python
```python
from threading import Thread, RLock, Semaphore, Event, Barrier
from threading import Thread, Timer, RLock, Semaphore, Event, Barrier
from concurrent.futures import ThreadPoolExecutor, as_completed
from concurrent.futures import ThreadPoolExecutor, as_completed
```
```
@ -2106,6 +2104,7 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
```
```
* **Use `'kwargs=<dict>'` to pass keyword arguments to the function.**
* **Use `'kwargs=<dict>'` to pass keyword arguments to the function.**
* **Use `'daemon=True'`, or the program will not be able to exit while the thread is alive.**
* **Use `'daemon=True'`, or the program will not be able to exit while the thread is alive.**
* **To delay thread execution use `'Timer(<float>, <func>)'` instead of Thread().**
### Lock
### Lock
```python
```python
@ -2129,7 +2128,7 @@ with <lock>: # Enters the block by calling acq
### Queue
### Queue
```python
```python
<Queue> = queue.Queue(maxsize=0) # A thread-safe FIFO queue. Also LifoQueue.
<Queue> = queue.Queue(maxsize=0) # A thread-safe first-in-first-out queue.
<Queue>.put(<el>) # Blocks until queue stops being full.
<Queue>.put(<el>) # Blocks until queue stops being full.
<Queue>.put_nowait(<el>) # Raises queue.Full exception if full.
<Queue>.put_nowait(<el>) # Raises queue.Full exception if full.
<el> = <Queue>.get() # Blocks until queue stops being empty.
<el> = <Queue>.get() # Blocks until queue stops being empty.
@ -2160,8 +2159,8 @@ Operator
**Module of functions that provide the functionality of operators. Functions are ordered by operator precedence, starting with least binding.**
**Module of functions that provide the functionality of operators. Functions are ordered by operator precedence, starting with least binding.**
```python
```python
import operator as op
import operator as op
<bool> = op.not_(<obj>) # not (or/and are not provided)
<li><strong>Aware <codeclass="apache hljs"><spanclass="hljs-section"><a></span></code> time and datetime objects have defined timezone, while naive <codeclass="apache hljs"><spanclass="hljs-section"><n></span></code> don't.</strong></li>
<li><strong>If object is naive, it is presumed to be in the system's timezone.</strong></li>
<li><strong>Aware <codeclass="apache hljs"><spanclass="hljs-section"><a></span></code> time and datetime objects have defined timezone, while naive <codeclass="apache hljs"><spanclass="hljs-section"><n></span></code> don't. If object is naive, it is presumed to be in the system's timezone!</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'fold=1'</span></code> means the second pass in case of time jumping back for one hour.</strong></li>
<li><strong><codeclass="python hljs"><spanclass="hljs-string">'fold=1'</span></code> means the second pass in case of time jumping back for one hour.</strong></li>
<li><strong>Timedelta normalizes arguments to ±days, seconds (< 86 400) and microseconds (< 1M).</strong></li>
<li><strong>Timedelta normalizes arguments to ±days, seconds (< 86 400) and microseconds (< 1M).</strong></li>
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'<D/DT>.weekday()'</span></code> to get the day of the week as an int, with Monday being 0.</strong></li>
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'<D/DT>.weekday()'</span></code> to get the day of the week as an int, with Monday being 0.</strong></li>
<div><h2id="array"><ahref="#array"name="array">#</a>Array</h2><p><strong>List that can only hold numbers of a predefined type. Available types and their minimum sizes in bytes are listed above. Sizes and byte order are always determined by the system, however bytes of each element can be swapped with byteswap() method.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> array <spanclass="hljs-keyword">import</span> array
<div><h2id="array"><ahref="#array"name="array">#</a>Array</h2><p><strong>List that can only hold numbers of a predefined type. Available types and their minimum sizes in bytes are listed above. Type sizes and byte order are always determined by the system, however bytes of each element can be swapped with byteswap() method.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">from</span> array <spanclass="hljs-keyword">import</span> array
<array> = array(<spanclass="hljs-string">'<typecode>'</span>, <collection>) <spanclass="hljs-comment"># Array from collection of numbers.</span>
<array> = array(<spanclass="hljs-string">'<typecode>'</span>, <collection>) <spanclass="hljs-comment"># Array from collection of numbers.</span>
<array> = array(<spanclass="hljs-string">'<typecode>'</span>, <bytes>) <spanclass="hljs-comment"># Array from bytes object.</span>
<array> = array(<spanclass="hljs-string">'<typecode>'</span>, <bytes>) <spanclass="hljs-comment"># Array from bytes object.</span>
<array> = array(<spanclass="hljs-string">'<typecode>'</span>, <array>) <spanclass="hljs-comment"># Treats array as a sequence of numbers.</span>
<array> = array(<spanclass="hljs-string">'<typecode>'</span>, <array>) <spanclass="hljs-comment"># Treats array as a sequence of numbers.</span>
<li><strong>CPython interpreter can only run a single thread at a time.</strong></li>
<li><strong>That is why using multiple threads won't result in a faster execution, unless at least one of the threads contains an I/O operation.</strong></li>
<li><strong>CPython interpreter can only run a single thread at a time. Using multiple threads won't result in a faster execution, unless at least one of the threads contains an I/O operation.</strong></li>
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'kwargs=<dict>'</span></code> to pass keyword arguments to the function.</strong></li>
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'kwargs=<dict>'</span></code> to pass keyword arguments to the function.</strong></li>
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'daemon=True'</span></code>, or the program will not be able to exit while the thread is alive.</strong></li>
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'daemon=True'</span></code>, or the program will not be able to exit while the thread is alive.</strong></li>
<li><strong>To delay thread execution use <codeclass="python hljs"><spanclass="hljs-string">'Timer(<float>, <func>)'</span></code> instead of Thread().</strong></li>
</ul>
</ul>
<div><h3id="lock">Lock</h3><pre><codeclass="python language-python hljs"><lock> = RLock() <spanclass="hljs-comment"># Lock that can only be released by acquirer.</span>
<div><h3id="lock">Lock</h3><pre><codeclass="python language-python hljs"><lock> = RLock() <spanclass="hljs-comment"># Lock that can only be released by acquirer.</span>
<lock>.acquire() <spanclass="hljs-comment"># Waits for the lock to be available.</span>
<lock>.acquire() <spanclass="hljs-comment"># Waits for the lock to be available.</span>
<li><strong>ProcessPoolExecutor provides true parallelism, but everything sent to/from workers must be <ahref="#pickle">pickable</a>. Queues must be sent using executor's 'initargs' and 'initializer' parameters.</strong></li>
<li><strong>ProcessPoolExecutor provides true parallelism, but everything sent to/from workers must be <ahref="#pickle">pickable</a>. Queues must be sent using executor's 'initargs' and 'initializer' parameters.</strong></li>
</ul>
</ul>
<div><h2id="operator"><ahref="#operator"name="operator">#</a>Operator</h2><p><strong>Module of functions that provide the functionality of operators. Functions are ordered by operator precedence, starting with least binding.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">import</span> operator <spanclass="hljs-keyword">as</span> op
<div><h2id="operator"><ahref="#operator"name="operator">#</a>Operator</h2><p><strong>Module of functions that provide the functionality of operators. Functions are ordered by operator precedence, starting with least binding.</strong></p><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">import</span> operator <spanclass="hljs-keyword">as</span> op
<bool> = op.not_(<obj>) <spanclass="hljs-comment"># not (or/and are not provided)</span>