Skip to content

Commit

Permalink
Remove ImmutableCint as cint objects are immutable
Browse files Browse the repository at this point in the history
See #19
  • Loading branch information
disconnect3d authored Nov 25, 2019
1 parent 6ca611a commit d399568
Showing 1 changed file with 2 additions and 27 deletions.
29 changes: 2 additions & 27 deletions cint/cint.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,31 +221,6 @@ def __ior__(self, other):
return self.__class__(self.value | calc(other))


class ImmutableCint(object):
pass

def create_immutable(val, type_):
class ImmutableCintX(type_, ImmutableCint):
def __not_implemented__(self, _):
raise NotImplementedError

__iadd__ = __not_implemented__
__isub__ = __not_implemented__
__imul__ = __not_implemented__
__ipow__ = __not_implemented__
__itruediv__ = __not_implemented__
__ifloordiv__ = __not_implemented__
__idiv__ = __not_implemented__ # Python 2 only
__imod__ = __not_implemented__
__irshift__ = __not_implemented__
__ilshift__ = __not_implemented__
__ior__ = __not_implemented__
__iand__ = __not_implemented__
__ixor__ = __not_implemented__

return ImmutableCintX(val)


class I8(Cint, ctypes.c_int8):
MIN = -2 ** 7
MAX = 2 ** 7 - 1
Expand Down Expand Up @@ -317,5 +292,5 @@ class U64(Cint, ctypes.c_uint64):

# fix/pin MIN/MAX values to be immutable (i.e. can't do U8.MIN += 2)
for _type in INTS:
_type.MIN = create_immutable(_type.MIN, _type)
_type.MAX = create_immutable(_type.MAX, _type)
_type.MIN = _type(_type.MIN)
_type.MAX = _type(_type.MAX)

0 comments on commit d399568

Please sign in to comment.