async tasks are cool, but the usual PSA applies here: Be careful to hold your references, because async tasks without active references will be garbage collected. I've been bitten by that in the past. Long discussion here: https://bugs.python.org/issue21163 Docs: https://docs.python.org/3/library/asyncio-task.html#asyncio.... "Important Save a reference to the result of this function, to avoid a task disappearing mid…
Overhead of Python asyncio tasks
11–20 of 88 posts
Re: Overhead of Python asyncio tasks
#12After running that code on both a Windows SB3 and major souped up Lenovo running Ubuntu...I just feel inadequate.
100,000 tasks 184,167 tasks per/s
200,000 tasks 160,964 tasks per/s
300,000 tasks 165,278 tasks per/s
400,000 tasks 149,577 tasks per/s
500,000 tasks 160,593 tasks per/s
600,000 tasks 168,098 tasks per/s
700,000 tasks 161,837 tasks per/s
800,000 tasks 160,364 tasks per/s
900,000 tasks 149,479 tasks per/s
1,000,000 tasks 155,919 tasks per/s
Re: Overhead of Python asyncio tasks
#13Reading this is like reading early Renaissance alchemist arguing about how much mercury they need to combine with how much silver to create gold... This is so far gone I don't even know where to begin... > It may be IO that gives AsyncIO its name, but Textual doesn't do any IO of its own. So why on Earth are you using AsyncIO? You don't need it, if that's true... > Those tasks are used to power message queues How are…
It's just using asyncio as a task scheduler, nothing more, nothing less. Maybe when you visit Pythonland you might instead be shocked in a more positive way :-)
Re: Overhead of Python asyncio tasks
#14Re: Overhead of Python asyncio tasks
#15Reading this is like reading early Renaissance alchemist arguing about how much mercury they need to combine with how much silver to create gold... This is so far gone I don't even know where to begin... > It may be IO that gives AsyncIO its name, but Textual doesn't do any IO of its own. So why on Earth are you using AsyncIO? You don't need it, if that's true... > Those tasks are used to power message queues How are…
>Needless to say that the whole benchmark is worthless
Overhead startup isn't worthless.
'I mean, I know, in Pythonland this is just your average Wednesday'
and here we go. The whole post was really just you trying to make out that you're superior to everyone else. In this case looking down on an entire ecosystem. Why? Python is one of the most popular languages. It has an elegant syntax and it's capable of solving most problems. Go jerk yourself off in private.
Re: Overhead of Python asyncio tasks
#16After running that code on both a Windows SB3 and major souped up Lenovo running Ubuntu...I just feel inadequate.
>> python3.10 create_task_overhead.py
100,000 tasks 185,694 tasks per/s
200,000 tasks 165,581 tasks per/s
300,000 tasks 170,857 tasks per/s
400,000 tasks 159,081 tasks per/s
500,000 tasks 162,640 tasks per/s
600,000 tasks 158,779 tasks per/s
700,000 tasks 161,779 tasks per/s
800,000 tasks 179,965 tasks per/s
900,000 tasks 160,913 tasks per/s
1,000,000 tasks 162,767 tasks per/s
>> python3.11 create_task_overhead.py
100,000 tasks 289,318 tasks per/s
200,000 tasks 265,293 tasks per/s
300,000 tasks 266,011 tasks per/s
400,000 tasks 259,821 tasks per/s
500,000 tasks 251,819 tasks per/s
600,000 tasks 267,441 tasks per/s
700,000 tasks 251,789 tasks per/s
800,000 tasks 254,303 tasks per/s
900,000 tasks 249,894 tasks per/s
1,000,000 tasks 266,581 tasks per/sRe: Overhead of Python asyncio tasks
#17Reading this is like reading early Renaissance alchemist arguing about how much mercury they need to combine with how much silver to create gold... This is so far gone I don't even know where to begin... > It may be IO that gives AsyncIO its name, but Textual doesn't do any IO of its own. So why on Earth are you using AsyncIO? You don't need it, if that's true... > Those tasks are used to power message queues How are…
>How are your message queues not doing I/O?
We generally wouldn't consider in-process moving data around to be "I/O", now if you started interacting with an external database/file/pipe/MMAP-ed-file/etc than that would be "I/O".
>What on Earth are they doing then?
Tasks. Kind of like processes but lighter weight. Running an event loop, dispatching signals, that sort of thing. You can do all that by manually writing your own event loop but python's asyncio (IMO) makes it easier to reason about exactly when your yielding the event loop to some other task, and makes it easier to write code that can yield control of the event loop at arbitrary places. So like if you want to update a widget every 10 seconds you can write something like
while True:
await asyncio.sleep(10) #Other tasks can run during this 10 seconds sleep
#Update widget contents
Useful for stuff that needs to periodically poll data, like a process monitor, or even for just simple clock widgets.---
As an aside that cooperative multitasking can be really nice in micropython, where you can write tight loops in straight assembly if you need to and still get a pleasant task interface for managing higher level tasks/threads. Combined with some interrupt handlers it makes a pretty elegant real-time-ish operating system. (You probably need to manually deal with garbage collections though)
Re: Overhead of Python asyncio tasks
#18Reading this is like reading early Renaissance alchemist arguing about how much mercury they need to combine with how much silver to create gold... This is so far gone I don't even know where to begin... > It may be IO that gives AsyncIO its name, but Textual doesn't do any IO of its own. So why on Earth are you using AsyncIO? You don't need it, if that's true... > Those tasks are used to power message queues How are…
Re: Overhead of Python asyncio tasks
#19Re: Overhead of Python asyncio tasks
#20Why would you want a terminal emulator anywhere near python? Using python for lightweight system utility gui apps seems like using a hammer to screw in a nail. Yeah you can do it and modern hardware is fast enough that you probably won't care, but why??
How slow do you think python is?