diff --git a/README.md b/README.md index 0621d55..e0c12c1 100644 --- a/README.md +++ b/README.md @@ -1948,17 +1948,6 @@ from collections import deque .rotate(n=1) # Rotates elements to the right. ``` -### Example -```python ->>> a = deque([1, 2, 3], maxlen=3) ->>> a.append(4) -[2, 3, 4] ->>> a.appendleft(5) -[5, 2, 3] ->>> a.insert(1, 6) -IndexError: deque already at its maximum size -``` - Threading --------- @@ -2001,8 +1990,22 @@ with ThreadPoolExecutor(max_workers=None) as executor: ``` ```python - = .done() # Checks if thread has finished executing. - = .result() # Waits for thread to finish and returns result. + = .done() # Checks if thread has finished executing. + = .result() # Waits for thread to finish and returns result. +``` + +### Queue +* **A thread-safe FIFO queue. For LIFO queue use 'queue.LifoQueue'.** +```python +from queue import Queue + = Queue(maxsize=0) +``` + +```python +.put() # Blocks until queue has a free spot. +.put_nowait() # Raises queue.Full exception if full. + = .get() # Blocks until queue contains an item. + = .get_nowait() # Raises _queue.Empty exception if empty. ``` diff --git a/index.html b/index.html index f7274f0..95a2edd 100644 --- a/index.html +++ b/index.html @@ -1720,15 +1720,6 @@ cursor.execute('<query>', <dict/namedt <deque>.extendleft(<collection>) # Collection gets reversed. <deque>.rotate(n=1) # Rotates elements to the right. -

Example

>>> a = deque([1, 2, 3], maxlen=3)
->>> a.append(4)
-[2, 3, 4]
->>> a.appendleft(5)
-[5, 2, 3]
->>> a.insert(1, 6)
-IndexError: deque already at its maximum size
-
-

#Threading

  • CPython interpreter can only run a single thread at the time.
  • That is why using multiple threads won't result in a faster execution, unless there is an I/O operation in the thread.
  • @@ -1760,8 +1751,20 @@ lock.release() <Future> = executor.submit(<function>, <arg_1>, ...)
-
<bool> = <Future>.done()    # Checks if thread has finished executing.
-<obj>  = <Future>.result()  # Waits for thread to finish and returns result.
+
<bool> = <Future>.done()     # Checks if thread has finished executing.
+<obj>  = <Future>.result()   # Waits for thread to finish and returns result.
+
+

Queue

    +
  • A thread-safe FIFO queue. For LIFO queue use 'queue.LifoQueue'.
  • +
from queue import Queue
+<Queue> = Queue(maxsize=0)
+
+ + +
<Queue>.put(<el>)            # Blocks until queue has a free spot.
+<Queue>.put_nowait(<el>)     # Raises queue.Full exception if full.
+<el> = <Queue>.get()         # Blocks until queue contains an item.
+<el> = <Queue>.get_nowait()  # Raises _queue.Empty exception if empty.
 

#Operator

from operator import add, sub, mul, truediv, floordiv, mod, pow, neg, abs
 from operator import eq, ne, lt, le, gt, ge
@@ -2144,7 +2147,7 @@ right = [[0.1 ,  0.6<
 right = [[0.1, 0.6, 0.8], [0.1, 0.6, 0.8], [0.1, 0.6, 0.8]]  # Shape: (3, 3) <- !
 
-

3. If neither non-matching dimension has size 1, rise an error.

Example

For each point returns index of its nearest point ([0.1, 0.6, 0.8] => [1, 2, 1]):

>>> points = np.array([0.1, 0.6, 0.8])
+

3. If neither non-matching dimension has size 1, rise an error.

Example

For each point returns index of its nearest point ([0.1, 0.6, 0.8] => [1, 2, 1]):

>>> points = np.array([0.1, 0.6, 0.8])
 [ 0.1,  0.6,  0.8]
 >>> wrapped_points = points.reshape(3, 1)
 [[ 0.1],