I am writing a simple Tweepy application for fun, but am really limited to how many API calls I have (anywhere between 150 and 350). So to account for this I am looking for ways to cut calls. Tweepy has a cursor system built in. Eg:
# Iterate through all of the authenticated user's friends
for follower in tweepy.Cursor(api.followers).items():
follower.follow()
For those who are familiar with this library. Would the above example be more or less efficient than simply…
for follower in api.followers_ids():
api.follow(follower)
Are there any other advantages apart from simplicity to use the Cursor method over an iterative method?
Thanks in advance.
If I remember correctly from my use of
tweepy, aCursorobject automatically paginates overnmany elements… For instance, if there are 10,000 results, and Twitter returns (say) 200 at a time, then using theCursorwill return all 10,000 but will have to make a call to keep retrieving the next ones.OTOH,
api.followers_ids()only returns the first “page” of results, so maybe the first 100 or whatever.