[
https://issues.apache.org/jira/browse/BEAM-4008?focusedWorklogId=101893&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-101893
]
ASF GitHub Bot logged work on BEAM-4008:
----------------------------------------
Author: ASF GitHub Bot
Created on: 14/May/18 21:26
Start Date: 14/May/18 21:26
Worklog Time Spent: 10m
Work Description: robertwb commented on a change in pull request #5336:
[BEAM-4008] Futurize utils subpackage
URL: https://github.com/apache/beam/pull/5336#discussion_r188103724
##########
File path: sdks/python/apache_beam/utils/windowed_value.py
##########
@@ -178,33 +182,14 @@ def __repr__(self):
self.windows,
self.pane_info)
- def __hash__(self):
- return (hash(self.value) +
- 3 * self.timestamp_micros +
- 7 * hash(self.windows) +
- 11 * hash(self.pane_info))
-
- # We'd rather implement __eq__, but Cython supports that via __richcmp__
- # instead. Fortunately __cmp__ is understood by both (but not by Python 3).
- def __cmp__(left, right): # pylint: disable=no-self-argument
- """Compares left and right for equality.
-
- For performance reasons, doesn't actually impose an ordering
- on unequal values (always returning 1).
- """
- if type(left) is not type(right):
- return cmp(type(left), type(right))
+ def _key(self):
+ return self.value, self.timestamp_micros, self.windows, self.pane_info
- # TODO(robertwb): Avoid the type checks?
- # Returns False (0) if equal, and True (1) if not.
- return not WindowedValue._typed_eq(left, right)
+ def __eq__(self, other):
+ return type(self) == type(other) and self._key() == other._key()
Review comment:
__eq__ is a builtin (slots) method that is optimized automatically.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 101893)
Time Spent: 0.5h (was: 20m)
> Futurize and fix python 2 compatibility for utils subpackage
> ------------------------------------------------------------
>
> Key: BEAM-4008
> URL: https://issues.apache.org/jira/browse/BEAM-4008
> Project: Beam
> Issue Type: Sub-task
> Components: sdk-py-core
> Reporter: Robbe
> Assignee: Robbe
> Priority: Major
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)