Article: https://avi.im/blag/2021/fast-sqlite-inserts/
PyPy is really fast implementation of Python. (Recommended to be used under any case)
pycurl
: PycURL is python interface to libcurl. PycURL can be used to fetch objects identified by a URL from a Python program, similar to urllib Python module. Pycurl is mature, very fast and has lot of features.
safety
- reports vulnerabilities for Python.
pip3 install safety
safety check -r requirements.txt
glom
- working with data in python - Path based access for nested structures - declarative data transformation using lightweight - Pythonic specifications. (https://glom.readthedocs.io/en/latest/)
from glom import glom
target = {'a': {'b': {'c': 'd'}}}
glom(target, 'a.b.c') # returns 'd'
glom is very powerful and is a must to use with APIs and JSON. Here's the library: https://glom.readthedocs.io/en/latest/tutorial.html
Coalesce
>>> from glom import Coalesce
>>> target = {
... 'system': {
... 'planets': [
... {'name': 'earth', 'moons': 1},
... {'name': 'jupiter', 'moons': 69}
... ]
... }
... }
>>> spec = {
... 'planets': (Coalesce('system.planets', 'system.dwarf_planets'), ['name']),
... 'moons': (Coalesce('system.planets', 'system.dwarf_planets'), ['moons'])
... }
>>> pprint(glom(target, spec))
{'moons': [1, 69], 'planets': ['earth', 'jupiter']}
Logging in JSON
python-json-logger
: The most lightweight python for json logging.structlog
: https://www.structlog.org/en/stable/loguru
: https://github.com/Delgan/loguru(https://plumbum.readthedocs.io/en/latest/index.html)
Apart from shell-like syntax and handy shortcuts, the library provides local and remote command execution (over SSH), local and remote file-system paths, easy working-directory and environment manipulation, quick access to ANSI colors, and a programmatic Command-Line Interface (CLI) application toolkit. Now let’s see some code!
>>> ls = local["ls"]
>>> ls
LocalCommand(<LocalPath /bin/ls>)
>>> ls()
u'build.py\\ndist\\ndocs\\nLICENSE\\nplumbum\\nREADME.rst\\nsetup.py\\ntests\\ntodo.txt\\n'
>>> notepad = local["c:\\\\windows\\\\notepad.exe"]
>>> notepad() # Notepad window pops up
u'' # Notepad window is closed by user, command returns
>>> chain = ls["-a"] | grep["-v", "\\\\.py"] | wc["-l"]
>>> print chain
/bin/ls -a | /bin/grep -v '\\.py' | /usr/bin/wc -l
>>> chain()
u'13\\n'
Python - local webserver to display current server:
python -m SimpleHTTPServer