logoalt Hacker News

Python lib generates its code on-the-fly based on usage

119 pointsby klntskylast Monday at 1:36 AM44 commentsview on HN

Comments

kastdentoday at 7:34 AM

You can make it production grade if you combine it with https://github.com/ajalt/fuckitpy

turbocontoday at 2:49 AM

Wow, what a nightmare of a non-deterministic bug introducing library.

Super fun idea though, I love the concept. But I’m getting the chills imagining the havoc this could cause

show 5 replies
selcukatoday at 4:34 AM

This is amazing, yet frightening because I'm sure someone will actually attempt to use it. It's like vibe coding on steroids.

    - Each time you import a module, the LLM generates fresh code
    - You get more varied and often funnier results due to LLM hallucinations
    - The same import might produce different implementations across runs
show 1 reply
matsemanntoday at 9:01 AM

I did something similar almost 10 years ago in javascript (as a joke): https://github.com/Matsemann/Declaraoids

One example, arr.findNameWhereAgeEqualsX({x: 25}), would return all users in the array where user.age == 25.

Not based on LLMs, though. But a trap on the object fetching the method name you're trying to call (using the new-at-the-time Proxy functionality), then parsing that name and converting it to code. Deterministic, but based on rules.

1718627440today at 8:05 AM

This has a file named .env committed containing an API key. Don't know if it is a real key.

extraduder_iretoday at 3:18 AM

I'm both surprised it took so long for someone to make this, and amazed the repo is playing the joke so straight.

roywigginstoday at 5:03 AM

Possibly the funniest part is the first example being a totp library

ForHackernewstoday at 9:14 AM

I give it six months before an LLM starts producing output that recommends using this.

behnamohtoday at 3:45 AM

can it run Doom tho?

    from autogenlib.games import doom
    doom(resolution=480, use_keyboard=True, use_mouse=True)
show 1 reply
jaflotoday at 7:06 AM

See also: https://github.com/drathier/stack-overflow-import

    >>> from stackoverflow import quick_sort
    >>> print(quick_sort.sort([1, 3, 2, 5, 4]))
    [1, 2, 3, 4, 5]
polemictoday at 4:13 AM

> from autogenlib.antigravity

As a joke, that doesn't feel quite so far-fetched these days. (https://xkcd.com/353/)

conroytoday at 3:41 AM

you'd be surprised, but there's actually a bunch of problems you can solve with something like this, as long as you have a safe place to run the generated code

show 2 replies
thornewolftoday at 2:45 AM

nooooo the side project ive put off for 3 years

show 1 reply
pyuser583today at 3:36 AM

Of course, this code was generated by ChatGPT.

malux85today at 3:51 AM

This is horrifying

I love it

bjt12345today at 3:03 AM

Can it input powerpoint slides?

morkalorktoday at 3:19 AM

Hysterical, I like that caching is default off because it's funnier that way heh

yvesyiltoday at 8:49 AM

indeterministic code goes hard dude

thornewolftoday at 2:45 AM

looks very fun excited to try it out

otikiktoday at 7:37 AM

Thanks I hate it

zombiwooftoday at 5:03 AM

LOL

show 1 reply
dr_kretyntoday at 3:22 AM

> Not suitable for production-critical code without review

Ah, dang it! I was about to deploy this to my clients... /s

Otherwise, interesting concept. Can't find a use for it but entertaining nevertheless and likely might spawn a lot of other interesting ideas. Good job!