You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2218,7 +2218,7 @@ Introspection
2218
2218
-------------
2219
2219
```python
2220
2220
<list>=dir() # Local names of variables, functions, classes and modules.
2221
-
<dict>=vars() # Dict of local names and their objects. Also locals().
2221
+
<dict>=vars() # Dict of local names and their objects. Same as locals().
2222
2222
<dict>=globals() # Dict of global names and their objects, e.g. __builtin__.
2223
2223
```
2224
2224
@@ -2260,20 +2260,20 @@ from concurrent.futures import ThreadPoolExecutor, as_completed
2260
2260
```python
2261
2261
<lock>= Lock/RLock() # RLock can only be released by acquirer thread.
2262
2262
<lock>.acquire() # Blocks (waits) until lock becomes available.
2263
-
<lock>.release() #It makes the acquired lock available again.
2263
+
<lock>.release() #Releases the lock so it can be acquired again.
2264
2264
```
2265
2265
2266
2266
#### Or:
2267
2267
```python
2268
2268
with<lock>: # Enters the block by calling method acquire().
2269
-
...# Exits by calling release(), even on error.
2269
+
...# Exits it by calling release(), even on error.
2270
2270
```
2271
2271
2272
2272
### Semaphore, Event, Barrier
2273
2273
```python
2274
2274
<Semaphore>= Semaphore(value=1) # Lock that can be acquired by 'value' threads.
2275
2275
<Event>= Event() # Method wait() blocks until set() is called.
2276
-
<Barrier>= Barrier(n_times) # Wait() blocks until it's called n times.
2276
+
<Barrier>= Barrier(<int>) # Wait() blocks until it's called int times.
2277
2277
```
2278
2278
2279
2279
### Queue
@@ -2307,7 +2307,7 @@ with <lock>: # Enters the block by calling met
2307
2307
Coroutines
2308
2308
----------
2309
2309
***Coroutines have a lot in common with threads, but unlike threads, they only give up control when they call another coroutine and they don’t consume as much memory.**
2310
-
***Coroutine definition starts with `'async'` and its call with `'await'` keyword.**
2310
+
***Coroutine definition starts with `'async'`keyword and its call with `'await'`.**
2311
2311
***Use `'asyncio.run(<coroutine>)'` to start the first/main coroutine.**
<div><h2id="introspection"><ahref="#introspection" name="introspection">#</a>Introspection</h2><pre><codeclass="python language-python hljs"><list> = dir() <spanclass="hljs-comment"># Local names of variables, functions, classes and modules.</span>
1836
-
<dict> = vars() <spanclass="hljs-comment"># Dict of local names and their objects. Also locals().</span>
1836
+
<dict> = vars() <spanclass="hljs-comment"># Dict of local names and their objects. Same as locals().</span>
1837
1837
<dict> = globals() <spanclass="hljs-comment"># Dict of global names and their objects, e.g. __builtin__.</span>
<div><h3id="lock">Lock</h3><pre><codeclass="python language-python hljs"><lock> = Lock/RLock() <spanclass="hljs-comment"># RLock can only be released by acquirer thread.</span>
1867
1867
<lock>.acquire() <spanclass="hljs-comment"># Blocks (waits) until lock becomes available.</span>
1868
-
<lock>.release() <spanclass="hljs-comment"># It makes the acquired lock available again.</span>
1868
+
<lock>.release() <spanclass="hljs-comment"># Releases the lock so it can be acquired again.</span>
1869
1869
</code></pre></div>
1870
1870
1871
1871
<div><h4id="or-1">Or:</h4><pre><codeclass="python language-python hljs"><spanclass="hljs-keyword">with</span> <lock>: <spanclass="hljs-comment"># Enters the block by calling method acquire().</span>
1872
-
... <spanclass="hljs-comment"># Exits by calling release(), even on error.</span>
1872
+
... <spanclass="hljs-comment"># Exits it by calling release(), even on error.</span>
1873
1873
</code></pre></div>
1874
1874
1875
1875
<div><h3id="semaphoreeventbarrier">Semaphore, Event, Barrier</h3><pre><codeclass="python language-python hljs"><Semaphore> = Semaphore(value=<spanclass="hljs-number">1</span>) <spanclass="hljs-comment"># Lock that can be acquired by 'value' threads.</span>
1876
1876
<Event> = Event() <spanclass="hljs-comment"># Method wait() blocks until set() is called.</span>
1877
-
<Barrier> = Barrier(n_times) <spanclass="hljs-comment"># Wait() blocks until it's called n times.</span>
1877
+
<Barrier> = Barrier(<int>) <spanclass="hljs-comment"># Wait() blocks until it's called int times.</span>
<li><strong>Coroutines have a lot in common with threads, but unlike threads, they only give up control when they call another coroutine and they don’t consume as much memory.</strong></li>
1905
-
<li><strong>Coroutine definition starts with <codeclass="python hljs"><spanclass="hljs-string">'async'</span></code> and its call with <codeclass="python hljs"><spanclass="hljs-string">'await'</span></code> keyword.</strong></li>
1905
+
<li><strong>Coroutine definition starts with <codeclass="python hljs"><spanclass="hljs-string">'async'</span></code>keyword and its call with <codeclass="python hljs"><spanclass="hljs-string">'await'</span></code>.</strong></li>
1906
1906
<li><strong>Use <codeclass="python hljs"><spanclass="hljs-string">'asyncio.run(<coroutine>)'</span></code> to start the first/main coroutine.</strong></li>
P = collections.namedtuple(<spanclass="hljs-string">'P'</span>, <spanclass="hljs-string">'x y'</span>) <spanclass="hljs-comment"># Position (x and y coordinates).</span>
1923
1923
D = enum.Enum(<spanclass="hljs-string">'D'</span>, <spanclass="hljs-string">'n e s w'</span>) <spanclass="hljs-comment"># Direction (north, east, etc.).</span>
1924
-
W, H = <spanclass="hljs-number">15</span>, <spanclass="hljs-number">7</span><spanclass="hljs-comment"># Width and height constants.</span>
1924
+
W, H = <spanclass="hljs-number">15</span>, <spanclass="hljs-number">7</span><spanclass="hljs-comment"># Width and height of the field.</span>
Copy file name to clipboardExpand all lines: parse.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -122,7 +122,7 @@ const COROUTINES =
122
122
'\n'+
123
123
'P = collections.namedtuple(<span class="hljs-string">\'P\'</span>, <span class="hljs-string">\'x y\'</span>) <span class="hljs-comment"># Position (x and y coordinates).</span>\n'+
124
124
'D = enum.Enum(<span class="hljs-string">\'D\'</span>, <span class="hljs-string">\'n e s w\'</span>) <span class="hljs-comment"># Direction (north, east, etc.).</span>\n'+
125
-
'W, H = <span class="hljs-number">15</span>, <span class="hljs-number">7</span> <span class="hljs-comment"># Width and height constants.</span>\n'+
125
+
'W, H = <span class="hljs-number">15</span>, <span class="hljs-number">7</span> <span class="hljs-comment"># Width and height of the field.</span>\n'+
0 commit comments