mirror of
https://github.com/mnaberez/py65.git
synced 2025-01-16 03:30:01 +00:00
Support slices in __setitem__ and __getitem__ for Python 3
This commit is contained in:
parent
820f9ad4b9
commit
42c5b6fc5b
@ -16,6 +16,12 @@ class ObservableMemory:
|
||||
self._write_subscribers = defaultdict(list)
|
||||
|
||||
def __setitem__(self, address, value):
|
||||
if isinstance(address, slice):
|
||||
r = range(*address.indices(self.physMask + 1))
|
||||
for n, v in zip(r, value):
|
||||
self[n] = v
|
||||
return
|
||||
|
||||
address &= self.physMask
|
||||
callbacks = self._write_subscribers[address]
|
||||
|
||||
@ -27,6 +33,10 @@ class ObservableMemory:
|
||||
self._subject[address] = value
|
||||
|
||||
def __getitem__(self, address):
|
||||
if isinstance(address, slice):
|
||||
r = range(*address.indices(self.physMask + 1))
|
||||
return [ self[n] for n in r ]
|
||||
|
||||
address &= self.physMask
|
||||
callbacks = self._read_subscribers[address]
|
||||
final_result = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user