r/teenagersbutcode • • 23d ago • Mindblown 1 Bravo 1

Coded a thing Since C is faster than python, using c to execute python.

Post image
1.4k Upvotes

86 comments sorted by

79

u/kutac56 13 loves low level stuff 23d ago

r/programminghorror would like this

7

u/Fearless-Ad1469 21d ago

69 updoots, the perfect number

6

u/kutac56 13 loves low level stuff 21d ago

Someone ruined it

6

u/Fearless-Ad1469 21d ago

i fixed it :3

5

u/kutac56 13 loves low level stuff 21d ago

And someone else already ruined again lol :3

5

u/Fine_Salamander_8691 i love rust 20d ago

I fixed it

4

u/MarkWasHere0_0 21d ago

i fixed it

53

u/Background-Book-7404 OMEN 23d ago

galaxy brain

35

u/Plane_Unit9357 23d ago

Smarter the claude

23

u/mjmvideos 23d ago

Depending on which shell you use, typing that command at the prompt and hitting return is likely already using C to execute it.

17

u/YTriom1 Arch btw supremacy :3 23d ago

I use fish

5

u/Maxson5571 23d ago

Based

2

u/Minigun1239 23d ago

i used bash, looked too bland, i used zsh, i didn't like it, would rather use bash, and i used fish, im probably not going back unless i find a way you can mod bash or smth

1

u/Embarrassed_Ninja_27 23d ago

You can “mod” bash and zsh btw. Check out iris

1

u/YTriom1 Arch btw supremacy :3 21d ago

yeah except it'll be super slow

3

u/TheLuckyCuber999BACK 🧢 (C Assembly Python) 23d ago

Bash supremacy.

1

u/YTriom1 Arch btw supremacy :3 21d ago

No

1

u/woodcraftworld 21d ago

zsh supremacy

2

u/YTriom1 Arch btw supremacy :3 21d ago

zsh is just polished bash

1

u/TheLuckyCuber999BACK 🧢 (C Assembly Python) 21d ago

exactly bash is better

1

u/YTriom1 Arch btw supremacy :3 21d ago

fish is better than both, and is 100% memory safe :3

1

u/TheLuckyCuber999BACK 🧢 (C Assembly Python) 21d ago

bash is the vanilla. No stupid stuff.

2

u/possible_name 18d ago

no it isn't. vanilla is any bourne shell implementation without extra features.

1

u/YTriom1 Arch btw supremacy :3 21d ago

fish is not forked bash, it's its own thing and if built from scratch.

bash though is based on the Bourne Shell so it's not really "vanilla"

→ More replies (0)

1

u/TheLuckyCuber999BACK 🧢 (C Assembly Python) 21d ago

objectively wrong

1

u/TheLuckyCuber999BACK 🧢 (C Assembly Python) 21d ago

yes

1

u/YTriom1 Arch btw supremacy :3 21d ago

no

1

u/TheLuckyCuber999BACK 🧢 (C Assembly Python) 21d ago

yes

1

u/YTriom1 Arch btw supremacy :3 21d ago

no

1

u/wh1tepearl 20d ago

mksh supremacy

1

u/linux_transgirl 19d ago

ksh supremacy (I'm weird)

0

u/TheLuckyCuber999BACK 🧢 (C Assembly Python) 12d ago

at least not zsh

1

u/linux_transgirl 11d ago

zsh isn't really bad, it's just kinda slow

1

u/TheLuckyCuber999BACK 🧢 (C Assembly Python) 11d ago

yea it's not bad it's horrible

3

u/Still-Addition-1109 C/Lua/Python/VBScript 23d ago

forget the shell, depending on your Python implementation (which is most likely CPython, which is written in C) you might already be using C to execute Python

11

u/deanominecraft Rust 23d ago

"hello from world c" looks like you might already have a race condition somewhere

8

u/SheriffGamer332 23d ago

now std::process::Command this in rust to make it memory safe and blazingly fast

5

u/05-nery 23d ago

I guess bro 💔

4

u/matytyma 23d ago

That's what the -c flag is for, right? Right?

4

u/raewashere_ reading uninit memory 22d ago

better yet, run c in python

1

u/Alive_Particular4659 22d ago

If that's possible, then you could run c in python in c in python in c etc.

1

u/Fearless-Ad1469 21d ago

It reminds me of hypervisor inside an hypervisor inside an hypervisor type shit, nesting4

3

u/pcb_x86 23d ago

Ahh yes writing C code to run the bourne shell to start Cpython to interpret python

3

u/This-Employment-5642 Python 23d ago

Frankly genius

3

u/ucan_cay 22d ago

this is not memory safe I'll rewrite it in rust

2

u/Heavy_Computer2602 23d ago

who made this brilliance /j

2

u/BetterEquipment7084 23d ago

Use execvp, system just sends it to the shell

2

u/uglycaca123 Interested in coding 23d ago

you should use assembly to run python, i assure you it'll be twice as fast

2

u/________yourbestgf 22d ago

I use assembly for executing python

1

u/PresentAstronomer137 23d ago

brilliant, python speed issue solved

1

u/TheLuckyCuber999BACK 🧢 (C Assembly Python) 23d ago

ok bro whatever you say

1

u/Mecso2 23d ago

me when I want performant regexes in c++

1

u/ManRevvv 22d ago

An iq too high?

1

u/Intelligent_Comb_338 22d ago

it's faster use exec* functions

1

u/Dapper-Hedgehog7048 22d ago

You use Kate

1

u/Beginning-Try3200 21d ago

Wait, how did I not even notice that? I love Kate, I would never code an entire application in Kate. I use VS Code.

1

u/Dapper-Hedgehog7048 21d ago

Yeah Kate is pretty good stuff but I get you using VS code everyone has their own preferences

1

u/Kotoki5 22d ago

now watch me use rust to run c to run python! mwahahaha

1

u/KaliLugu 21d ago

big brain

1

u/DinoHawaii2021 Python/Lua/Java Dev | 18 21d ago

some python modules are also in c

1

u/PinguinLars 21d ago

now make it take user input and you got a cve

1

u/thatguy1000000000 20d ago

Lol. 

Funnily enough I made something like this

1

u/the_genius324 20d ago

for the love of God and all that is holy, please use python.h instead of this

1

u/Comfortable_Bed4844 18d ago

are you fucking serious right now

1

u/that_one_mc_player 17d ago

Holy optimisation 🤑 🤑 🤑

1

u/ABSOLUTE-DEVELOPER 4d ago

No it doesn't work that way, it's just the same python but slower by a miniscule fraction of a second. but maybe if you use Python to execute Python (PyPy) it could be faster.

And no please don't do
import os; os.system("python3 -c \"print('Hello from world python')\"")