tp_richcompare

  • Thread starter Sreeram Kandallu
  • Start date
S

Sreeram Kandallu

I'm writing an extension type, for which i'd like to implement only ==
and !=, but not the other comparison operators like <,<=,>,>=.
What is the right way to do this?
I currently have a tp_richcompare function, which handles Py_EQ, and
Py_NE, but raises a TypeError for the other operations. Is this the
'right' way?

Sreeram


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEf9p7rgn0plK5qqURAnSpAKC11jsqYi4bD0S60bImpa5Z3z5FfgCcDobq
tdibxRCzqXwku4pi3v28wuk=
=cI/9
-----END PGP SIGNATURE-----
 
Z

Ziga Seilnacht

Sreeram said:
I'm writing an extension type, for which i'd like to implement only ==
and !=, but not the other comparison operators like <,<=,>,>=.
What is the right way to do this?
I currently have a tp_richcompare function, which handles Py_EQ, and
Py_NE, but raises a TypeError for the other operations. Is this the
'right' way?

Yes. This is exactly what the builtin complex type does.

Ziga
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top