Permalink
Browse files

only getentry on the branch the first time it is accessed in an event

  • Loading branch information...
1 parent 637b17b commit ca91740be585c88ca975359f80e4d5c9e18619af @ndawe ndawe committed Jul 2, 2012
Showing with 4 additions and 3 deletions.
  1. +4 −3 rootpy/tree/tree.py
View
@@ -712,6 +712,7 @@ def set_tree(self, tree=None):
def next_entry(self):
+ self._branch_cache = {}
self._current_entry += 1
def __setattr__(self, attr, value):
@@ -743,9 +744,9 @@ def __getattr__(self, attr):
attr = self._fixed_names[attr]
try:
if self._tree is not None:
- try:
- self._branch_cache[attr].GetEntry(self._current_entry)
- except KeyError: # one-time hit
+ if attr not in self._branch_cache:
+ # attr branch is being accessed for the first time in this
+ # event
branch = self._tree.GetBranch(attr)
if not branch:
raise AttributeError

0 comments on commit ca91740

Please sign in to comment.