我想从我的键列表中提取所有对象。有比我现在的做法更好的方法吗?
list_of_objs = []
for obj_key in list_of_keys:
this_obj = db.get(obj.key)
list_of_objs.append(this_obj)
最佳答案
根据documentation db.get 可以接受键列表并在单个批处理中获取它们,这会快得多。
list_of_objects = db.get(list_of_keys)
关于python - 从键列表中获取对象的最佳方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23999361/