Specifically the 'build_details' tuple contains a lot of wasted references, and we hold on to one of these for each record we are fetching. And for something like 'bzr pack', that is all keys.
For just loading all text build details on my bzr+ repository, With: locations = b.repository.texts._index.get_build_details(b.repository.texts.keys()) This drops the memory consumption from: WorkingSize 77604KiB to WorkingSize 64640KiB
Or around 10.6MB. I worked it out to a savings of about 80 bytes/record on data that can have hundreds of thousands of records (in 32-bit).