“Quando perdiamo il diritto di essere differenti, perdiamo il privilegio di essere liberi”
Which roughly translates to: “when we lose the right to be different, we also lose the privilege of freedom”
This powerful sentence was used by the President of Republic of Italy Sergio Mattarella on December 31st 2019 when he addressed the whole nation.
Not sure about you but I find it utterly beautiful and inspiring.
Today I spent most of the day jumping around to reach Naples downtown: the sheer decay of the whole region here is beyond upsetting.
Unfortunately it’s also because of me and people like me: we decided to leave altogether; by doing so we gave free reign to whoever stayed behind... the braindeads and the douchebags.
I Was Google’s Head of International Relations. Here’s Why I Left.
Now we can add that to our pool; it's as easy as pie...:
list_of_slow_callables = 
'''Add an egregous number of slow functions to our list.'''
for i in range(100):
"""The cool part: kickoff the executor using the default number
of worker threads (at most 32).
with concurrent.futures.ThreadPoolExecutor() as tp:
for func in list_of_slow_callables:
Let's start with our ol' fashioned function...
'''This is a dummy long function, replace it with your stuff.'''
logging.debug('Really, not doing anything particular for several seconds...')
for i in range(10):
logging.debug('Ok, I\'m done')
Need a quick (and not that dirty) way to parallelize some Python call?
Here's how to do it: just submit (add) your function to the ThreadPoolExecutor.
Every callable (functions, ndr) submitted to the pool returns a Future. But you don't really need to care about that for now.
Talking is cheap, though, let me show you the code.
(This is gonna be a short thread)
In the past few years the Python release schedule changed quite a bit and it might become a bit complicated to understand what version to pick.
* there's a major version per year
* a major version is supported for up to 5 years
To get a graphical idea of this concept, bookmark this page: https://python-release-cycle.glitch.me
The current major version (the one you should all target for new stuff) is Python 3.8.
An arrogant bastard
🇮🇹 weirdo in 🇺🇸 doing 🖥 stuff
The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!