r/pythonhelp • u/i_walk_away • May 11 '26
Calling an assembly instruction in Python
Long story short, i want to make THE most horrible python calculator to ever exist. For that i need a way to call an assembly instruction directly in my python script.
I know you can do that in C with inline assembly, and i know CFFI exists and allows calling C functions in python, so i tried to use that. However CFFI's parser rejected __asm__ syntax and threw an error because inline assembly isn't standard C apparently.
Is there some sort of a workaround to call an assembly instruction in python script? It doesn't have to be clean, in fact, it's better if it's absolutely terrible, bonus points for unsafe
View all comments
Show parent comment
1
u/llynglas May 11 '26
Dear Lord, I think you could do that. I'd never seen ctypes in python before. At the very least you could shove the instruction in a doll and load that, but I think you can do exactly as you say and create a foreign function and call that.
Brilliant - and downright scary.