Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"sorted" usage should be eliminated during get-next calls #8

Open
tombo315 opened this issue Feb 4, 2017 · 0 comments
Open

"sorted" usage should be eliminated during get-next calls #8

tombo315 opened this issue Feb 4, 2017 · 0 comments

Comments

@tombo315
Copy link
Contributor

tombo315 commented Feb 4, 2017

Ideally (as-implemented):

  • O(1) for gets
  • O(n) for get-next

Currently:

We can have the table maintain a sorted copy of the keys for fast get-next calls.

class MIBTable(dict):
   # ...
  def __setitem__(self, key, value):
      super().__setitem__(key, value)
      self._sorted_keys = sorted(self.keys())

  @property
  def sorted_keys():
      # make a copy -- saves OID searches "in-flight" if the table is updated
      return list(self._sorted_keys)
@tombo315 tombo315 changed the title sorted usage should be eliminated during lookups "sorted" usage should be eliminated during get-next calls Feb 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant