Browse Source

Added slots

pull/36/head
Jure Šorn 5 years ago
parent
commit
67a16d744c
2 changed files with 2 additions and 2 deletions
  1. 2
      README.md
  2. 2
      index.html

2
README.md

@ -1036,7 +1036,7 @@ class <class_name>:
### Slots
**Mechanism that restricts objects to attributes listed in 'slots' and significantly reduces their memory footprint.**
```
```python
class MyClassWithSlots:
__slots__ = ['a']
def __init__(self):

2
index.html

@ -976,7 +976,7 @@ Z = dataclasses.make_dataclass(<span class="hljs-string">'Z'</span>, [<span clas
</ul>
<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 hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyClassWithSlots</span>:</span>
<pre><code class="python language-python hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">MyClassWithSlots</span>:</span>
__slots__ = [<span class="hljs-string">'a'</span>]
<span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">__init__</span><span class="hljs-params">(self)</span>:</span>
self.a = <span class="hljs-number">1</span>

Loading…
Cancel
Save