Skip to content

Commit 4cbaa25

Browse files
committed
feat(magic): hash for complex
1 parent f0a5af7 commit 4cbaa25

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎Objects/numobjects/complexobjectImpl.nim‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import pkg/pycomplex
1313

1414
from ./floatobject/toval import PyFloat_AsDouble
1515
from ./floatobject/fromx import PyNumber_Float
16+
import ./floatobject/hashes
1617
import ../noneobject
1718
import ../typeobject/apis/attrs
1819
import ../../Include/internal/pycore_global_strings
@@ -114,7 +115,10 @@ implComplexMethod "__format__"(arg: PyStrObject):
114115

115116
implComplexMagic repr: newPyAscii pycomplex.repr(self.v)
116117

118+
proc hash*(self: PyComplexObject): Hash =
119+
complex_hash_impl(self, Py_HashDouble)
117120

121+
implComplexMagic hash: newPyInt hash self
118122

119123
template genBop(op){.dirty.} =
120124
proc op*(self, other: PyComplexObject): `PyComplexObject` =

0 commit comments

Comments
 (0)