I have a layer and I would like to access the number of rows the attribute table has from my code. Is there a way to do that without doing it like this:
num_of_features = 0
for feat in layer.getFeatures():
num_of_features += 1
print(num_of_features)