-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Speedup deepcopy for Rating objects (#108)
* Speedup deepcopy Signed-off-by: Vivek Joshy <8206808+vivekjoshy@users.noreply.github.com> * Add changelog Signed-off-by: Vivek Joshy <8206808+vivekjoshy@users.noreply.github.com> --------- Signed-off-by: Vivek Joshy <8206808+vivekjoshy@users.noreply.github.com>
- Loading branch information
1 parent
a03847b
commit 4cf5d7d
Showing
6 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Optimize rating objects for deepcopy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
""" | ||
import copy | ||
import itertools | ||
import marshal | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
vivekjoshy
Author
Owner
|
||
import math | ||
import uuid | ||
from functools import reduce | ||
|
@@ -74,6 +75,11 @@ def __str__(self) -> str: | |
def __hash__(self) -> int: | ||
return hash((self.id, self.mu, self.sigma)) | ||
|
||
def __deepcopy__(self, memodict={}): | ||
plr = PlackettLuceRating(self.mu, self.sigma, self.name) | ||
plr.id = self.id | ||
return plr | ||
|
||
def __eq__(self, other: object) -> bool: | ||
if isinstance(other, PlackettLuceRating): | ||
if self.mu == other.mu and self.sigma == other.sigma: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I am assuming this was added intially to perform the serialization but was not used in the end. I suggest removing this import.