Skip to content

Commit

Permalink
[perf] fastpath getitemdeep
Browse files Browse the repository at this point in the history
  • Loading branch information
saulpw committed Nov 30, 2023
1 parent d362033 commit c324fca
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions visidata/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ def setattrdeep(obj, attr, val, getter=getattr, setter=setattr):


def getitemdeep(obj, k, *default):
if not isinstance(k, str):
return obj[k]
return getattrdeep(obj, k, *default, getter=getitem)

def setitemdeep(obj, k, val):
Expand Down

0 comments on commit c324fca

Please # to comment.