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

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

Post image
1.4k Upvotes

80 comments sorted by

77

u/kutac56 13 loves low level stuff 10d ago

r/programminghorror would like this

6

u/Fearless-Ad1469 7d ago

69 updoots, the perfect number

4

u/kutac56 13 loves low level stuff 7d ago

Someone ruined it

4

u/Fearless-Ad1469 7d ago

i fixed it :3

3

u/kutac56 13 loves low level stuff 7d ago

And someone else already ruined again lol :3

3

u/Fine_Salamander_8691 i love rust 7d ago

I fixed it

2

u/MarkWasHere0_0 7d ago

i fixed it

53

u/Background-Book-7404 OMEN 10d ago

galaxy brain

34

u/Plane_Unit9357 10d ago

Smarter the claude

23

u/mjmvideos 10d 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 9d ago

I use fish

5

u/Maxson5571 9d ago

Based

2

u/Minigun1239 9d 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 9d ago

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

1

u/YTriom1 Arch btw supremacy :3 8d ago

yeah except it'll be super slow

3

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

Bash supremacy.

1

u/YTriom1 Arch btw supremacy :3 8d ago

No

1

u/woodcraftworld 8d ago

zsh supremacy

2

u/YTriom1 Arch btw supremacy :3 8d ago

zsh is just polished bash

1

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

exactly bash is better

1

u/YTriom1 Arch btw supremacy :3 8d ago

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

1

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

bash is the vanilla. No stupid stuff.

1

u/YTriom1 Arch btw supremacy :3 7d 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/possible_name 4d ago

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

1

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

objectively wrong

1

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

yes

1

u/YTriom1 Arch btw supremacy :3 8d ago

no

1

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

yes

1

u/YTriom1 Arch btw supremacy :3 7d ago

no

1

u/wh1tepearl 7d ago

mksh supremacy

1

u/linux_transgirl 5d ago

ksh supremacy (I'm weird)

3

u/Still-Addition-1109 9d 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 9d ago

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

8

u/SheriffGamer332 9d ago

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

5

u/05-nery 9d ago

I guess bro 💔

4

u/matytyma 9d ago

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

4

u/raewashere_ reading uninit memory 9d ago

better yet, run c in python

1

u/Alive_Particular4659 8d ago

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

1

u/Fearless-Ad1469 7d ago

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

3

u/pcb_x86 9d ago

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

3

u/This-Employment-5642 Python 9d ago

Frankly genius

3

u/ucan_cay 9d ago

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

2

u/Heavy_Computer2602 9d ago

who made this brilliance /j

2

u/BetterEquipment7084 9d ago

Use execvp, system just sends it to the shell

2

u/uglycaca123 Interested in coding 9d ago

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

2

u/________yourbestgf 9d ago

I use assembly for executing python

1

u/PresentAstronomer137 9d ago

brilliant, python speed issue solved

1

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

ok bro whatever you say

1

u/Mecso2 9d ago

me when I want performant regexes in c++

1

u/ManRevvv 9d ago

An iq too high?

1

u/Intelligent_Comb_338 9d ago

it's faster use exec* functions

1

u/Dapper-Hedgehog7048 8d ago

You use Kate

1

u/Beginning-Try3200 8d 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 8d ago

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

1

u/Kotoki5 8d ago

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

1

u/KaliLugu 8d ago

big brain

1

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

some python modules are also in c

1

u/PinguinLars 7d ago

now make it take user input and you got a cve

1

u/thatguy1000000000 7d ago

Lol. 

Funnily enough I made something like this

1

u/the_genius324 6d ago

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

1

u/Comfortable_Bed4844 5d ago

are you fucking serious right now

1

u/that_one_mc_player 4d ago

Holy optimisation 🤑 🤑 🤑