File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,8 +10,8 @@ cdef class Eapi(Indirect):
1010 # cached fields
1111 cdef OrderedFrozenSet dep_keys
1212 cdef OrderedFrozenSet metadata_keys
13- cdef str id
14- cdef int hash
13+ cdef str _id
14+ cdef int _hash
1515
1616 @staticmethod
1717 cdef Eapi from_ptr(const C.Eapi * , bint init = * )
Original file line number Diff line number Diff line change @@ -87,8 +87,6 @@ cdef class Eapi(Indirect):
8787 if init:
8888 eapi = < Eapi> Eapi.__new__ (Eapi)
8989 eapi.ptr = ptr
90- eapi.id = cstring_to_str(C.pkgcraft_eapi_as_str(ptr))
91- eapi.hash = C.pkgcraft_eapi_hash(ptr)
9290 else :
9391 id = cstring_to_str(C.pkgcraft_eapi_as_str(ptr))
9492 eapi = EAPIS[id ]
@@ -213,15 +211,19 @@ cdef class Eapi(Indirect):
213211 return NotImplemented
214212
215213 def __str__ (self ):
216- return self .id
214+ if self ._id is None :
215+ self ._id = cstring_to_str(C.pkgcraft_eapi_as_str(self .ptr))
216+ return self ._id
217217
218218 def __repr__ (self ):
219219 addr = < size_t> & self .ptr
220220 name = self .__class__.__name__
221221 return f" <{name} '{self}' at 0x{addr:0x}>"
222222
223223 def __hash__ (self ):
224- return self .hash
224+ if not self ._hash:
225+ self ._hash = C.pkgcraft_eapi_hash(self .ptr)
226+ return self ._hash
225227
226228 def __reduce__ (self ):
227- return Eapi.from_obj, (self .id ,)
229+ return Eapi.from_obj, (str ( self ) ,)
You can’t perform that action at this time.
0 commit comments