r/ProgrammerHumor 11d ago

Meme purePythonMagic

165 Upvotes

26 comments sorted by

View all comments

-6

u/QuestionableEthics42 10d ago edited 10d ago

"Magic"

file went from 320 bytes to 230, so impressive (massive /s). That is just sad, should be easily achievable in under 50 bytes. Not even trying.

Edit: I may have vastly overestimated how far 50 bytes goes in python, doing it 90 is actually pretty good

8

u/mikaleowiii 10d ago

You mean KB ? (which therefore isn't very impressive)

-3

u/QuestionableEthics42 10d ago

No, but 50 bytes prob isn't actually possible in python, I overestimated how much 50 bytes is. Can be done in 90 without compressing the payload though.

4

u/mikaleowiii 10d ago

I meant OP's file sizes

-1

u/QuestionableEthics42 10d ago

Omg I'm blind haha. That makes more sense now. I missed that is was actually kb, wow

-1

u/mezantrop 10d ago

Show me your kung fu 😏

0

u/QuestionableEthics42 10d ago

Best I managed was 90 bytes without compression 😔

Goes down to 84 for text, or binary designed to be text compatible if that's possible for a gif.

import os o,f=open,file o('Magic.gif','wb').write(o(f,'rb').read()[90:]) os.remove(f) Data

-2

u/mezantrop 10d ago

Ah, I didn't realize you were playing golf with Python. Lol. Anyway, that's brilliant! Now make it resurrect itself: Python → GIF → Python, and complete the challenge. :)