-
Notifications
You must be signed in to change notification settings - Fork 11
Add a thing to make using BufferCollator as some sort of queue easy and ... #4
base: master
Are you sure you want to change the base?
Conversation
@@ -187,9 +187,16 @@ API Reference | |||
|
|||
Adds the contents of a view to the collator. | |||
|
|||
.. method:: collapse() | |||
.. method:: collapse(max_bytes=-1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Below you called it max_length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uhh, where?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. In the imlementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
@@ -453,16 +452,29 @@ def append(self, view): | |||
self._views.append(view) | |||
self._total_length += len(view) | |||
|
|||
def collapse(self): | |||
def collapse(self, max_bytes=-1): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not None instead of a sentinel value?
(ok, so technically None is a sentinel value, but at least it is of a different type)
Also, have you considered making collapse a non-destructive operation? it could just create a buffer and leave the old stuff there. You'd need to allow passing a start index in addition to a max_bytes, though. |
...fast