'Number of entities this query fetches.
Beware: count() ignores the LIMIT clause on GQL queries.
Args:
limit: A number. If there are more results than this, stop short and
just return this number. Providing this argument makes the count
operation more efficient.
kwargs: Any keyword arguments accepted by datastore_query.QueryOptions().
Returns:
Number of entities this query fetches.'

def count(self, limit=1000, **kwargs):

    raw_query = self._get_query()
    result = raw_query.Count(limit=limit, **kwargs)
    self._last_raw_query = raw_query
    return result
