Skip to content

Commit 21a24e7

Browse files
committed
Relax port equality criterion
Now all types of ports can be compared. A Port instance is equal to an OwnPort instance, if they wrap the same port pointer (which can happen if multiple client objects were created).
1 parent 94642ea commit 21a24e7

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

‎jack.py‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,6 +1370,14 @@ def __init__(self, port_ptr):
13701370
def __repr__(self):
13711371
return "jack.{0.__class__.__name__}({0.name!r})".format(self)
13721372

1373+
def __eq__(self, other):
1374+
"""Ports are equal if their underlying port pointers are."""
1375+
return self._ptr == other._ptr
1376+
1377+
def __ne__(self, other):
1378+
"""This should be implemented whenever __eq__() is implemented."""
1379+
return not self.__eq__(other)
1380+
13731381
@property
13741382
def name(self):
13751383
"""Full name of the JACK port (read-only)."""
@@ -1503,15 +1511,6 @@ def __init__(self, port_ptr, client):
15031511
Port.__init__(self, port_ptr)
15041512
self._client = client
15051513

1506-
def __eq__(self, other):
1507-
"""This is needed for list.remove() in unregister()."""
1508-
return (self._ptr == other._ptr and
1509-
self._client._ptr == other._client._ptr)
1510-
1511-
def __ne__(self, other):
1512-
"""This should be implemented whenever __eq__() is implemented."""
1513-
return not self.__eq__(other)
1514-
15151514
@property
15161515
def number_of_connections(self):
15171516
"""Number of connections to or from port."""

0 commit comments

Comments
 (0)