473,507 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

tp_richcompare

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

iD8DBQFEf9p7rgn0plK5qqURAnSpAKC11jsqYi4bD0S60bImpa 5Z3z5FfgCcDobq
tdibxRCzqXwku4pi3v28wuk=
=cI/9
-----END PGP SIGNATURE-----

Jun 2 '06 #1
1 1382
Sreeram Kandallu wrote:
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.
Sreeram


Ziga

Jun 2 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
11482
by: John Hunter | last post by:
I have a list of two tuples containing x and y coord (x0, y0) (x1, y1) ... (xn, yn) Given a new point x,y, I would like to find the point in the list closest to x,y. I have to do this a...
3
1769
by: Thomas Mailund | last post by:
Hi group. I have a problem with some C extensions I am working with and hope that some of you can help. Basically, I am wrapping a a tree structure from C where I have python methods for...
2
1981
by: James S | last post by:
Hi, Basically I've been fighting with this code for a few days now and can't seem to work around this problem. Included is the output, the program I use to get this error and the source code for...
0
1258
by: Neal D. Becker | last post by:
I'm using boost::python to transform various C++ classes and functions to python. It is all working quite well, but now I'm having trouble with documentation tools. I hope someone can tell me...
0
1036
by: harold fellermann | last post by:
Am I stupid or what? I want to implement a very simple extension class in C (as I did it many times before...) The python equivalent of my class whould look like: class physics_DPD : def...
2
3759
by: Bryan Olson | last post by:
The current Python standard library provides two cryptographic hash functions: MD5 and SHA-1 . The authors of MD5 originally stated: It is conjectured that it is computationally infeasible to...
2
4427
by: ajikoe | last post by:
Hi, I tried to follow the example in swig homepage. I found error which I don't understand. I use bcc32, I already include directory where my python.h exist in bcc32.cfg. /* File : example.c...
0
1060
by: Uwe Hoffmann | last post by:
Hi, i have used Pyrex to build some python Extensionclasses. Now i stumbled over the fact that if a subclass has a __hash__ method the __richcmp__ of the base is not called. # pseudocode ...
9
2184
by: Emanuele Aina | last post by:
I have some code which does a lot of "in" on lists containing objects with no __eq__ defined. It all goes fast until I add the __lt__() method: then I have a slowdown comparable to the one I get...
0
7319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7031
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7485
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5042
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.