Please enable JavaScript.
Coggle requires JavaScript to display documents.
Python - Coggle Diagram
Python
Python - Master the Art of Design Patterns
Monostate
__dict__ : storage
__sharedState__
Thread
Global interpreter lock : take one thread
Thread overhead
solution : pooling
Cython, Gevent (ex. eel for gui) : can release GIL
Multiprocessing
cpu_count() : simultaneity
pool
map_async
streaming results
map
apply_async
closed
no extra tasks
Queue
results_queue.get() :<3: : make sure it is small
++Sharing
Manager : distribution
++concurrency
--by default overwrites data locally : incoherence
heavy computations
with low data passing
concurrent.futures : promise
I/O
with ThreadPoolExecutor
many
with ProcessPoolExecutor
limited
--Sharing : avoid globals
asyncio : p417
asyncio.coroutine
futures : [asyncio.async(function)]
.get_event_loop().run_until_complete(future)
yield
from asyncio.doSomething(futures)
control goes to
yield
from asyncio.sleep(2)
JSON use is better than lists in ProcessPoolExecutor
yield from
: for streaming
loop.set_default_
executor()
readexactly buffers read untill receiving all
run-length encoding : p420
bitarray : 0 & 1
Interpreter
for advanced UX end experienced domain specific DSL users
Observer
RabbitMQ package
pass by a Broker
200MB(modifiable) as a start
Fluent Python
Design patterns
Command
Decorator (wrapt)
name
Time count page197
functools
functools.lru_cache()
singledispatch
nonlocal : free variable in closure
Crafts
Sorting
Sorted(x,key=type)
LookUp behaviour
globals()[name]
__name__ =='__main__'
weakref
Caching
First class functions
Data types
Containers
Dict
Set
Contain any type (unlike flat sequences)
Queue
Multiprocessing
For interprocess comm
Dequeue
Thread safe
Fast push pop at both ends
Set
Many Containment checks
Array
MemoryView
NumPy without math
Shared mem
array.tofile() Fast from/to file
Big data containment
Tuple
Collections.namedtuple
Tuple unpacking
Parallel assignment
Immutable
List
Slicing [1:3]
Built-in
Pickle : fast I/O with files
Im/Mutable sequences
Flat sequences
Container sequences