def count(session, query):
 counts = query.selectable.with_only_columns([func.count()])
 num_results = session.execute(counts.order_by(None)).scalar()
 if ((num_results is None) or (query._limit is not None)):
  return query.order_by(None).count()
 return num_results

def count ( session , query ) : counts = query . selectable . with_only_columns ( [ func . count ( ) ] ) num_results = session . execute ( counts . order_by ( None ) ) . scalar ( ) if ( ( num_results is None ) or ( query . _limit is not None ) ) : return query . order_by ( None ) . count ( ) return num_results
get the count of properties for a namespace .