Python is Too Slow

preview_player
Показать описание
Recorded Offline at 26.09.2021

References:

Support:

Feel free to use this video to make highlights and upload them to YouTube (also please put the link to this channel in the description)
Рекомендации по теме
Комментарии
Автор

Once your language becomes self-hosted (compiler written in your own language) so that you no longer have to bootstrap, that will be an amazing feeling for anyone involved in the project.

Hobbitstomper
Автор

"Python is not slower than C!"

*shows code that has byte magic, and assembly in the middle*

pedro_alonso
Автор

14:03 yes, you can set 0 to the first enumerand and the auto() will follow.

jorgegomes
Автор

Very cool video, seeing the process of profiling and troubleshooting porth was incredibly entertaining. The only thing I can think of that could be improved is the distinct lack of green frogs. In your future videos consider including more green frogs.

purplemossclump
Автор

The fact that 15 million appends was 100 seconds in your interpreter and was 6 seconds with pops in the stack stresstest tells me that your if ladder for all ops is very slow and could be optimized by putting common operations earlier in the ladder and potentially by eliminating it altogether and turning it into a map lookup to find a function pointer to call.

keldwikchaldain
Автор

"oh don't tell me he switches to C AGAIN!!!"

kisinja
Автор

I made sim run many times faster by avoiding the "elifs" with a map of functions. Alternatively, just putting the most common intrinsics like DUP, SWAP, DROP etc first in the "elifs" already makes it noticeably faster, for obvious reasons.
I find sim pretty usable now actually. With pypy, euler problem04 takes 10 seconds, and my PC is clocking at like a 1GHz, so.

petros_adamopoulos
Автор

If you're a beginner learning Python, don't worry because this is the right time. By the time you're pretty good at python, version 3.11 will be released, which targets a 2x performance improvement of the vanilla interpreter (CPython)

FADHsquared
Автор

30:07 One simple optimization for the stack is to initialize it with a sequence of zeroes of some size (maybe 1k is enough) and and instead of pushing and popping, you just do common getitem and setitem, with help of some sort "stack pointer" local var. Probably append and pop deals with memory allocation/freeing and maybe that's what makes it slow.

jorgegomes
Автор

28:55 knowing exactly just how slow python is, I was thinking “oh dear, you’re in for a surprise, boss” 😂
I spat my drink when he was like “are you fucking kidding me??”

HaouasLeDocteur
Автор

In college we could choose which language we used for algorithms homework, there were run duration requirements for full marks and people who used python got a 5x time bonus because it’s so much slower. I’ll never forget that.

Diamonddrake
Автор

when I see you struggle with the Python enum, I'm so happy with the way Go does enumerations xD

LaPingvino
Автор

That's why I'm writing python compiler

monsieuralexandergulbu
Автор

22:26 "that's why I'm unemployed"
That cracked me up. xD

greob
Автор

cython is also a cool alternative if you like python syntax. It compiles python code to C with "appropriate" levels of interaction with Python's C libraries. It has been around for a long time.

A bit of a learning curve, but I think it works quite nicely.

dareason
Автор

You should consider hiding operations that weren't used from displaying and maybe even sorting list by time or use count

adrianpolv
Автор

Surely the Go version should be called Gorth? :)

ZXK
Автор

Love the content, love the voice and the quality of the audio. Just one recommendation, you should use a de-esser or eq to lo the sibilance in your S and CH, you could make it a preset and forget about it for the rest of your youtube carreer!. Amazing content! Keep it up

penndrive
Автор

If i'm not mistaken, python's pop for lists is O(N). Try switching to a O(1) implementation. It should be as easy as :
```
from collections import deque
stack = deque()
```

mateuscanelhas
Автор

Tso did you try to run porth.py with python -O (disabled asserts) to check if it runs any faster?

eukaryote