I create a quick part of my application that looks at the followers of users, and highlights who are followed by people who follow the user (friends).
I am interested in two things:
Is there a more efficient way to do this? It looks like this will launch the Twitter API restrictions, because I need to check the friends of each of the user's friends.
This creates a list of dicts containing the identifier of the friend and the followers that they follow. Instead, a dict would be better as an identifier for a follower and then friends who follow them. Advice?
the code:
followers = api.GetFollowerIDs()['ids']
friends = api.GetFriendIDs()['ids']
followers_not_friends = set(followers).difference(friends)
followers_that_friends_follow = []
for f in friends:
ff = api.GetFriendIDs(f)['ids']
users = followers_not_friends.intersection(ff)
followers_that_friends_follow.append({'friend': f, 'users': users })
source
share