Skip to content
Smiley Barry edited this page Sep 20, 2013 · 1 revision

SteamAPI is based around objects, and each object contains a multitude of properties. If retrieved normally, each object would take an immense amount of time to create. Thus, the library makes use of lazily-retrieved properties.

Let's take SteamUser as an example:

>>> me = user.SteamUser(12345678901234567890)
>>> dir(me)
['avatar', 'avatar_full', 'avatar_medium', 'badges', 'country_code', 'currently_playing', 'friends', ...]

All of these properties are lazily-fetched, but one of them is especially costly: friends. When we get a user's friends list, we make a request to the Steam Web API for the list of IDs that comprise his/her friends. We then pre-cache player data on all of the IDs (in large chunks to save time) and make them into individual SteamUser objects. We then cache the data to make next requests instantaneous.

Lazy-retrieval is the default for all properties, except for unique IDs (AppIDs, Steam 64-bit IDs, etc.). Sometimes, like with person.friends, we pre-cache some data if we can do so quicker than manual requests would, saving time. For example, GetPlayerSummaries, the API we use to retrieve public user data, allows to request more than one user's info at a time, so in cases like person.friends we use it to request user data in chunks of ~35 users, reducing the amount of time that would be spent by up to 35x.

Clone this wiki locally