24,628 karma · joined Oct 21, 2019 (7y ago) · 5,512 submissions
https://www.bitecode.dev/
Email: contact at bitecode.dev
comment 5y ago · link · parent
Well, that question is as old as engineering itself, and it's always a matter of resources, cost, history and knowledge.
comment 5y ago · link · parent
It has been proposed to Python: https://groups.google.com/g/python-ideas/c/PN1_j7Md4j0/m/0xy...
But I have no more info about it.
comment 5y ago · link · parent
Besides, it's weird, like saying we should not have int, float and complex, there should be one way to do it.
Just because those are 3 numbers doesn't mean they don't have each their own specific benefit.
comment 5y ago · link · parent
Not sure it will get there, but it would be nice. I think putting a top level "await" is explicit enough for stating you want an event loop anyway.
Now, with TaskGroup in 3.11, things are going to get pretty nice, espacially if this top level await plays out, provided they include async for and async with in the mix.
Now, if they could just make so that coroutines are automatically schedules to the nearest task group, we would almost have something usable.
comment 5y ago · link · parent
And since we are stuck with colored functions in python, the choice of stack matters very much.
Now, if you want easier concurrency, and a solution to a lot of concurrency problems that curio solves, while still being compatible with asyncio, use anyio:
https://anyio.readthedocs.io/en/stable/
It's a layer that works on top of asyncio, so it's compatible with all of it. But it features the nursery concept from Trio, which makes async programming so much simpler and safer.
comment 5y ago · link · parent
comment 5y ago · link · parent
- The event loop in JS is invisible and implicit. V8 proved it can be done without paying a cost for it, and in fact most real life python projects are using uvloop because it's faster than asyncio default loop. JS dev don't think of the loop at all, because it's always been there. They don't have to chose a loop, or thinking about its lifecycle or scheduling. The API doesn't show the loop at all.
- Asynchronous functions in JS are scheduled automatically. On python, calling a coroutine function does...nothing. You have to either await it, or pass it to something like asyncio.create_task(). The later is not only verbose, it's not intuitive.
- Async JS functions can be called from sync functions transparently. It just returns a Promise after all, and you can use good old callbacks. Instantiating a Python coroutine does... nothing as we said. You need to schedule it AND await it. If you don't, it may or may not be executed. Which is why asyncio.gather() and co are to be used in python. Most people don't know that, and even if you know, it's verbose, and you can forget. All that, again, because using the event loop must be explicit. That's one thing TaskGroup from trio will help with in the next Python versions...
- the early asyncio API sucked. The new one is ok, asyncio.run() and create_task() with implicit loop is a huge improvement. But you better use 3.7 at least. And you have to think about all the options for awaiting: https://stackoverflow.com/questions/42231161/asyncio-gather-...
- asyncio tutorials and docs are not great, people have no idea how to use it. Since it's more complex, it compounds.
E.G, if you use await:
With node v14.8+:
await async_func(params)
With python 3.7+: import asyncio
async def main():
# no top level await, it must happen in a loop
await async_func(params)
asyncio.run(main) # explicit loop, but easy one thanks to 3.7
E.G, deep inside functions calls, but no await:With node:
...
async_func(params)
With python 3.7+: ...
# async_func(params) alone would do nothing
res = asyncio.create_task(async_func(params))
...
# you MAY get away with not using gather() or wait()
# but you also may get "coroutine is never awaited"
# RuntimeWarning: coroutine 'async_func' was never awaited
asyncio.gather(res)
Of course, you could use "run_until_complete()", but then you would be blocking. Which is just not possible in JS, there is one way to do it, and it's always non blocking and easy. Ironic, isn't it? Beside, which Python dev knows all this? I'm guessing most readers of this post will have heard of it for the first time.Python is my favorite language, and I can live with the explicit loop, but explicit scheduling is ridiculous. Just run the damn coroutine, I'm not instantiating it for the beauty of it. If I want a lazy construct, I can always make a factory.
Now, thanks to the trio nursery concept, we will get TaskGroup in the next release (also you can already use them with anyio):
async with asyncio.TaskGroup() as tg:
tg.start_soon(async_func, params)
Which, while still verbose, is way better:- no gather or wait. Schedule it, it will run or be cleaned up.
- no need to chose an awaiting strat, or learn about a 1000 things. This works for every cases. Wanna use it in a sync call ? Pass the tg reference in it.
- lifecycle is cleanly scoped, a real problem with a lot of async code (including in JS, where it doesn't have a clean solution)
comment 5y ago · link · parent
In fact, it's a perfectly viable strat in python to have several processes, each having several threads, each having an event loop.
And it will still be so, once this comes out. You will certainly use threads more, and processes less, but replacing 1000000 coroutines by 1000000 system threads is not necessarily the right strategy for your task. See nginx vs apache.
comment 5y ago · link · parent
But if you are a fan of the original story, it's a spit in the face of a masterpiece.
The title, names and arcs are basically used for branding.
It was predictable, the Foundation cycle is mostly dialogs spanned over hundreds of years. Little details is given to action, and characters, which are superficially developed and serve mostly the purpose of a vehicle for history, die of old age every few chapters or so.
Very hard to adapt, and pretty much impossible to make money outside of the show, with the face of your actors, by selling toys or pretty symbols. Also, good luck keeping hooked the general public. There is no focus on sexuality, little humor, hardly anyone relatable, they talk a lot then goodbye.
So they made it a block buster. It sure can work, but it's not Foundation.
comment 5y ago · link · parent
In the first minutes it's already game over: they try to get you interested in the human characters in a book where the main protagonist is an entire galaxy over centuries. All named persons are going to die every 3 chapters, I get that you can't get ROI on your expensive hot actors faces, but that makes no sense for the material you work with!
comment 5y ago · link · parent
There is always somebody to say that in those kind of threads. Same as Vi is easy, try Manjaro, Nix, this latest implementation of LISP, that NoSQL db, this DSL, etc.
I used to give them the benefit of the doubt, spend some time testing the alternative the person talked about, came out disappointed, and wasted time.
Now I just trust numbers. When 100 people like you will tell me the same for 3 years, I will try.
Before that, I'll stay on what I know works.
comment 5y ago · link · parent
I understand the rational to also push for wayland first now, but it breaks my workflow for things like autokey. We do need to move from X11, but once again, something I will have to work with.
And now Firefox is a snap, which is slow, has permissions problems all around (guaranteed the sandbox will break some addons), takes a lot of space, etc. Again, I get it, it's a perfect candidate to push the tech, and they need to solve user facing apps distribution problem with linux.
I like Ubuntu a lot. I donate to it. I don't want to migrate to Manjaro or something else. Ubuntu is the sweet spot for things working out of the box.
But with 21.010, I really feel like at least moving to Elementary or PopOS right now. Tried them, the first one can't install (EFI partition is too small), the second breaks on my machine.
I don't like KDE, so I guess, next is Xubuntu? Something else?
comment 5y ago · link · parent
You can, have all that with debian, but then you have to do the work.
I don't want to do the work if canonical can do it for me.
comment 5y ago · link · parent
Just like I won't tell myself "I'm going to apply the strategy pattern here".
We just see the situation, and if it calls from a solution from the banks of solutions we have encountered in the past, we see if it fits, we try to apply it if it does (tailoring may be necessary).
Then the commentator later may say "oh, he decided to use Y". But that's for the benefits of the people watching.
comment 5y ago · link · parent
- "Can you send me back the card?"
- "I'm in a train, I won't be able to do that for a while. You should really call"
- "But I don't have the number"
- "I can read it to you"
Pwn
comment 5y ago · link · parent
When you name something "factory", when some doc mentions "dependency injection", when you import a "register", when you talk with a colleague about a "decodator", if you know the name, you already know what it does, and what the API will probably look like.
I say probably, because we don't have a format definition of all design patterns, nor are they all recognized as such. For for the ones that are and we do, we don't all agree. Not to mention you must adapt them to problems and languages.
So sure, when you code and you encounter a problem, you may use a design pattern. But you don't explicitly do so. Just like a chess master doesn't chose a move by thinking "I'm going to use x", they just decide on it, and also adapt it to the situation.
I never think about design patterns when I code, only when I name the code, I write the doc, and talk about it. When I communicate.
If you read a book about design patterns, they will make no sense to you. You will probably misuse them. But if you look at real life source codes from other devs, or yours again and again, you realize some problems come back often, and a lot of people use similar solutions. Then you look it up: bingo, it has a name.
That's how it works, not the other way around. It's formalization of real life, not theory to apply.
comment 5y ago · link · parent
Banking in britanic banking system is way easier than anywhere else. I remember when I was a student, they sent a bus to the university, so we could just hop in, arrive at the bank, and open an account as an immigrant in 15 minutes.
Try to do that in France, you would get your card, what, next month at best?
It was only a matter of time before the criminals realize the door was unlocked and feast on them.
In fact, I'm expecting Australia to be next, for the very same reasons.
Have you tried to do any paper work in Australia ? It's. So. Simple. Seriously, for a french, it's a video game on easy mode, and you never leave the tutorial.
But there is trust everywhere.
They are either going down, or make the system harder to work with.
comment 5y ago · link · parent
TL;DR: the author has working code for a CPython 3.9 implementation that gets rid of the GIL, works with most C extensions (albeit requiring to compile them again), and with better perfs _including_ for single threaded programs.
The report is worth read, very clear, professional, and humble, which for such a complex achievement, is quite a thing by itself.