|
54 | 54 |
|
55 | 55 | <body>
|
56 | 56 | <header>
|
57 |
| - <aside>April 13, 2023</aside> |
| 57 | + <aside>May 26, 2023</aside> |
58 | 58 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
|
59 | 59 | </header>
|
60 | 60 |
|
|
903 | 903 | <class> = make_dataclass(<span class="hljs-string">'<class_name>'</span>, <coll_of_tuples>)
|
904 | 904 | <tuple> = (<span class="hljs-string">'<attr_name>'</span>, <type> [, <default_value>])</code></pre></div>
|
905 | 905 |
|
906 |
| -<div><h4 id="restoftypeannotationscpythoninterpreterignoresthemall">Rest of type annotations (CPython interpreter ignores them all):</h4><pre><code class="python language-python hljs"><span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">func</span><span class="hljs-params">(<arg_name>: <type> [= <obj>])</span> -> <type>:</span> ... |
907 |
| -<var_name>: typing.List/Set/Iterable/Sequence/Optional[<type>] |
908 |
| -<var_name>: typing.Dict/Tuple/Union[<type>, ...] |
| 906 | +<div><h4 id="restoftypeannotationscpythoninterpreterignoresthemall">Rest of type annotations (CPython interpreter ignores them all):</h4><pre><code class="python language-python hljs"><span class="hljs-keyword">import</span> typing <span class="hljs-keyword">as</span> tp, collections.abc <span class="hljs-keyword">as</span> abc |
| 907 | +<var_name>: list/set/abc.Iterable/abc.Sequence/tp.Optional[<type>] [= <obj>] |
| 908 | +<var_name>: dict/tuple/tp.Union[<type>, ...] [= <obj>] |
| 909 | +<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">func</span><span class="hljs-params">(<arg_name>: <type> [= <obj>])</span> -> <type>:</span> ... |
909 | 910 | </code></pre></div>
|
910 | 911 |
|
911 | 912 | <div><h3 id="slots">Slots</h3><p><strong>Mechanism that restricts objects to attributes listed in 'slots' and significantly reduces their memory footprint.</strong></p><pre><code class="python language-python hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyClassWithSlots</span>:</span>
|
@@ -2935,7 +2936,7 @@ <h3 id="format-2">Format</h3><div><h4 id="forstandardtypesizesandmanualalignment
|
2935 | 2936 |
|
2936 | 2937 |
|
2937 | 2938 | <footer>
|
2938 |
| - <aside>April 13, 2023</aside> |
| 2939 | + <aside>May 26, 2023</aside> |
2939 | 2940 | <a href="https://gto76.github.io" rel="author">Jure Šorn</a>
|
2940 | 2941 | </footer>
|
2941 | 2942 |
|
|
0 commit comments