Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions src/uproot/behaviors/TBranch.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import sys
import threading
from collections.abc import Iterable, Mapping, MutableMapping
from keyword import iskeyword

import numpy

Expand Down Expand Up @@ -1977,11 +1978,11 @@ def index(self):
:ref:`uproot.behaviors.TBranch.TBranch.name` is not unique: the
non-recursive index is always unique.
"""
for i, branch in enumerate(self.parent.branches):
if branch is self:
return i
else:
raise AssertionError
if not hasattr(self, "_index"):
# cache index of all branches of the parent to avoid repeating this loop for other branches
for i, branch in enumerate(self.parent.branches):
branch._index = i
return self._index

@property
def interpretation(self):
Expand Down Expand Up @@ -2921,9 +2922,14 @@ def _regularize_expressions(
uproot.interpretation.grouped.AsGrouped,
),
):
branchname_expression = (
branchname
if branchname.isidentifier() and not iskeyword(branchname)
else language.getter_of(branchname)
)
_regularize_expression(
hasbranches,
language.getter_of(branchname),
branchname_expression,
keys,
aliases,
language,
Expand Down
Loading