Hacker News new | past | comments | ask | show | jobs | submit login

I have not used Peewee, but at first sight the most visible difference is the query syntax - Peewee uses method chaining, whereas Pony ORM decompiles Python AST. I think that many queries can look simpler in Pony than in Pewee.

For example, if I want to retrieve all pairs of different users with the same name, in Pony this query would look as follow:

    select((u1, u2) for u1 in User for u2 in User if u1.name == u2.name and u1 != u2)
In Peewee, this query probably would look something like this (didn't test it):

    User2 = User.alias()
    User.select(User, User2).join(User2).where((User.name == User2.name) & (User.id != User2.id))
It’s probable the matter of taste, but I like Pony syntax better. Another example is taken from the Peewee doc:

    staff_users = User.select().where(is_staff=True)
    Tweet.select().where(~(Tweet.user << staff_users))
In Pony, this query would look as follow:

    select(t for t in Tweet if t.user not in (u for u in User if u.is_staff))
    
Also, this simple version is possible, don't know why it is not as simple in Peewee

    select(t for t in tweet if not t.user.is_staff)
Also, I don’t know if Peewee supports IdentityMap and optimistics transactions.

On there other side, it seems Peewee already has migration support, whereas in Pony migrations are not implemented yet, this is the next task.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: