Skip to content
Discussion options

You must be logged in to vote

I see what they're going for but uhhhhhh, that seems... overly complicated.

MicroPython does not support modifying the type of a class instance at runtime. You actually could make this work though by just replacing the relevant methods:

class RingBuffer:
    """ class that implements a not-yet-full buffer """
    def __init__(self,size_max):
        self.max = size_max
        self.data = []

      def _full_append(self, x):
          """ Append an element overwriting the oldest one. """
          self.data[self.cur] = x
          print("data:", self.data, "cur:",self.cur)
          self.cur = (self.cur+1) % self.max
          print("next cur:",self.cur)
      def _full_get(self):
       …

Replies: 6 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by Wind-stormger
Comment options

You must be logged in to vote
1 reply
@Wind-stormger
Comment options

Comment options

You must be logged in to vote
1 reply
@Wind-stormger
Comment options

Comment options

You must be logged in to vote
3 replies
@Wind-stormger
Comment options

@peterhinch
Comment options

@rkompass
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants