Which Python System is affected? (Was: What does the Async Detour usually cost)

2025-06-23 Thread Mild Shock
Bye Mild Shock schrieb: Hi, I have some data what the Async Detour usually costs. I just compared with another Java Prolog that didn't do the thread thingy. Reported measurement with the async Java Prolog: > JDK 24: 50 ms (using Threads, not yet VirtualThreads) New additional measur

What does the Async Detour usually cost (Was: What does stats = await asyncio.to_thread(os.stat, url) do?)

2025-06-23 Thread Mild Shock
mtime and doing some comparisons. Mild Shock schrieb: So what does: stats = await asyncio.to_thread(os.stat, url) Whell it calls in a sparate new secondary thread: os.stat(url) It happends that url is only a file path, and the file path points to an existing file. So the secondary thread computs th

What does stats = await asyncio.to_thread(os.stat, url) do? (Was async I/O via threads is extremly slow)

2025-06-23 Thread Mild Shock
50 ms (using Threads, not yet VirtualThreads) > pypy: 2000 ms I am only using one main task, sequentially on such await calles, with a couple of file, not more than 50 files. I could compare with removing the async detour, to qualify the async I/O detour overhead. Mild Shock schrieb: Hi, asy

async I/O via threads is extremly slow (Was: Does Python Need Virtual Threads?)

2025-06-23 Thread Mild Shock
itten in the test case, only "mtime" was read, via this Python line: stats = await asyncio.to_thread(os.stat, url) Bye Mild Shock schrieb: Concerning virtual threads the only problem with Java I have is, that JDK 17 doesn't have them. And some linux distributions are stuck wit

Re: Does Python Need Virtual Threads? (Posting On Python-List Prohibited)

2025-06-14 Thread Mild Shock
Concerning virtual threads the only problem with Java I have is, that JDK 17 doesn't have them. And some linux distributions are stuck with JDK 17. Otherwise its not an idea that belongs solely to Java, I think golang pioniered them with their goroutines. I am planning to use them more heavily

Re: Await expressions

2024-01-27 Thread Mild Shock via Python-list
We say that an object is an awaitable object if it can be used in an await expression. Many asyncio APIs are designed to accept awaitables. There are three main types of awaitable objects: coroutines, Tasks, and Futures. Stefan Ram schrieb: In "The Python Language Reference, Release 3.13

Re: Await expressions

2024-01-27 Thread Mild Shock via Python-list
Maybe consult: PEP 492 – Coroutines with async and await syntax Created: 09-Apr-2015 Python-Version: 3.5 https://peps.python.org/pep-0492/ Mild Shock schrieb: We say that an object is an awaitable object if it can be used in an await expression. Many asyncio APIs are designed to accept

Re: Await expressions (Posting On Python-List Prohibited)

2024-02-03 Thread Mild Shock via Python-list
I am still waiting for async files in the style of nodejs that works on windows and is bundled with the main python distribution. I am not very fond on doing something like adding listeners to a file descriptor, in nodejs async files are based on callbacks not on listeners. Whats the roadmap

Re: Await expressions (Posting On Python-List Prohibited)

2024-02-03 Thread Mild Shock via Python-list
And whats the roadmap for an asyncified module loader, is this on the radar of Python? Mild Shock schrieb: I am still waiting for async files in the style of nodejs that works on windows and is bundled with the main python distribution. I am not very  fond on doing something like adding

Re: Await expressions (Posting On Python-List Prohibited)

2024-02-03 Thread Mild Shock via Python-list
+0100, Mild Shock wrote: ... that works on windows ... You lost me there. -- https://mail.python.org/mailman/listinfo/python-list

Re: Await expressions (Posting On Python-List Prohibited)

2024-02-03 Thread Mild Shock via Python-list
userspace. Mild Shock schrieb: The docu tells me: Windows loop.add_reader() and loop.add_writer() only accept socket handles (e.g. pipe file descriptors are not supported). https://docs.python.org/3/library/asyncio-platforms.html Alternatives are aiofiles and anyio and maybe more, but not sure

Re: Python told me a Joke

2024-09-03 Thread Mild Shock via Python-list
You can try: >>> 1,2 == 2,2 (1, True, 2) Its the same as: >>> 1, (2 == 2), 2 (1, True, 2) Hope this helps! Alan Bawden schrieb: Python 3.10.5 (v3.10.5:f37715, Jul 10 2022, 00:26:17) [GCC 4.9.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>>

Re: Two aces up Python's sleeve

2024-11-08 Thread Mild Shock via Python-list
dress. Greg Ewing schrieb: On 8/11/24 3:04 am, Mild Shock wrote: This only works for small integers. I guess this is because tagged pointers are used nowadays ? No, it's because integers in a certain small range are cached. Not sure what the actual range is nowadays, it used to be some

Re: Two aces up Python's sleeve

2024-11-08 Thread Mild Shock via Python-list
cdaca8, Oct 15 2024, 20:08:21) >>> x, y = 257, 257 >>> id(x) == id(y) True Mild Shock schrieb: Hi, In Java its possible to work this way with the Integer datatype, just call Integer.valueOf(). I am not sure whether CPython does the same. Because it shows me the same behaviour fo

Re: Two aces up Python's sleeve

2024-11-08 Thread Mild Shock via Python-list
The wiked brain of ChatGPT gives me a lead: PEP 659 Storing data caches before the bytecode. Maybe its an effect of constant folding and constant pooling by the compiler? Mild Shock schrieb: For example this article: https://www.codementor.io/@arpitbhayani/python-caches-integers-16jih595jk

Re: Two aces up Python's sleeve (Posting On Python-List Prohibited)

2024-11-08 Thread Mild Shock via Python-list
Well you can use your Browser, since JavaScript understand post and pre increment: > x = 5 5 > x ++ 5 > x = 5 5 > ++ x 6 So we have x ++ equals in Python: x + = 1 x - 1 And ++ x equals in Python: x += 1 x But I don't know how to combine an assignment and an expression into on

Re: Two aces up Python's sleeve

2024-11-08 Thread Mild Shock via Python-list
This only works for small integers. I guess this is because tagged pointers are used nowadays ? For large integers, also known as bigint, it doesn't work: Python 3.13.0a1 (tags/v3.13.0a1:ad056f0, Oct 13 2023, 09:51:17) >>> x, y = 5, 4+1 >>> id(x) == id(y) True >>> x, y = 10**200, 10**199*10 >>