hynek / characteristic

Please use attrs instead!
https://attrs.readthedocs.io/
MIT License
84 stars 19 forks source link

Split with_cmp into with_eq_hash and with_ordering? #23

Closed Julian closed 4 years ago

Julian commented 9 years ago

Quite often I want to define equality on objects by all or most of the attributes, but ordering by a different, smaller subset. Or, similarly, sometimes I want equality + hashing so that I can use them for set membership, but I don't want ordering, which is often meaningless.

Thoughts?

hynek commented 9 years ago

It’s meaningless, but is it worth the added complexity? I guess I’d rather add a ordering=True argument or something?

Julian commented 9 years ago

Most of the advantage of the with_* is composing them seemingly? I thought you'd generally want to prefer allowing more composition -- if you have just an argument, you can't say, apply ordering selectively to some thing that exists already.

But I don't care much personally, to me it'd just be nice if there was a way to split them at all without characteristic overriding an __lt__ that I define.

hynek commented 9 years ago

Composition kind of went out of the window when we decided (you were part of that decision at EP ;)) to ditch the idea of separating attribute definition from specifying what to do on them. :-/

So to me it sounds right now like:

  1. it’s extra complexity
  2. it looks like a breaking change (hence my suggestion of ordering=True)
  3. it’s a rather fringy case

Am I missing something?

Julian commented 4 years ago

(Don't mind me, I'm just clearing out my own GH issues tab on things that'll never be needed... Sorry for the inbox spam y'all.)