2018-05-24, 16:51
Thanks @Wintermute0110. I had looked at that exact same article, as well as this one.
I'm just finishing up a new release of my addon for v18 and have come up with the following scheme:
1) Parse archived data from an xml file to a dict, in a format that can just be called directly from xbmcgui.ListItem
2) Minimize the calls to xbmcgui.ListItem to 3. One to create the list, one for setInfo, one for setArt
3) Save those parsed xml lists to json files for faster loading after the list was parsed
4) Keep a copy of the current list/dict in memory using json (for faster loading when the user is just browsing the list in various ways)
5) Send them to kodi using xbmcgui.ListItem(... offscreen=True)
This seems to be as good as I can get it. Step 3 I tried using both pickle.load / pickle.dump and json.load / json.dump. Indeed with a large list, json did speed things up even more (although the times are in the ms difference for a list of ~5000).
Steps 4 and 5 have sped up displaying a large list dramatically, over 20x faster. Even on an RPi its almost snappy. The offscreen=True option should almost be the default in my opinion, or at least in the documentation as a best practice.
In the future, i might play around with some of those other data serialization methods. MessagePack seems promising, but someone would have to package that up to work with Kodi.
I'm just finishing up a new release of my addon for v18 and have come up with the following scheme:
1) Parse archived data from an xml file to a dict, in a format that can just be called directly from xbmcgui.ListItem
2) Minimize the calls to xbmcgui.ListItem to 3. One to create the list, one for setInfo, one for setArt
3) Save those parsed xml lists to json files for faster loading after the list was parsed
4) Keep a copy of the current list/dict in memory using json (for faster loading when the user is just browsing the list in various ways)
5) Send them to kodi using xbmcgui.ListItem(... offscreen=True)
This seems to be as good as I can get it. Step 3 I tried using both pickle.load / pickle.dump and json.load / json.dump. Indeed with a large list, json did speed things up even more (although the times are in the ms difference for a list of ~5000).
Steps 4 and 5 have sped up displaying a large list dramatically, over 20x faster. Even on an RPi its almost snappy. The offscreen=True option should almost be the default in my opinion, or at least in the documentation as a best practice.
In the future, i might play around with some of those other data serialization methods. MessagePack seems promising, but someone would have to package that up to work with Kodi.