Skip to content

Commit

Permalink
Merge pull request #1195 from python-trio/memory-channel-state-slots
Browse files Browse the repository at this point in the history
Use slots for channel state and statistics.
  • Loading branch information
njsmith authored Aug 20, 2019
2 parents 9496a59 + 8bafbb2 commit ce7c40c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions newsfragments/1195.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use slots for memory channel state and statistics which should make memory channels slightly smaller and faster.
4 changes: 2 additions & 2 deletions trio/_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def open_memory_channel(max_buffer_size):
)


@attr.s(frozen=True)
@attr.s(frozen=True, slots=True)
class MemoryChannelStats:
current_buffer_used = attr.ib()
max_buffer_size = attr.ib()
Expand All @@ -79,7 +79,7 @@ class MemoryChannelStats:
tasks_waiting_receive = attr.ib()


@attr.s
@attr.s(slots=True)
class MemoryChannelState:
max_buffer_size = attr.ib()
data = attr.ib(factory=deque)
Expand Down

0 comments on commit ce7c40c

Please sign in to comment.