I'm trying to determine if a  or git commit is needed in a git repository. I come up with this code that works fine for me :
def is_dirty(repo):
  import pygit2
  status = repo.status()
  for filepath, flags in status.items():
    if flags != pygit2.GIT_STATUS_CURRENT:
        if flags != 16384:
            return True
  return False;
But this is extremely inefficient : the repo.status() takes forever -- at least compared to the git status command line.
So my question is : is there a more efficient way to know if the repository is clean ?
PS : I'm using python3. With python2 I used the module git that has a is_dirty function.
 
     
     
    