python2.7 - python 2.7中有async for的等价表达方式吗?
巴扎黑
巴扎黑 2017-04-18 10:12:48
0
2
989
巴扎黑
巴扎黑

reply all(2)
刘奇

Changing it to asynchronous is not of much use. Your situation is very computationally intensive, and your time should be spent on "key in need_cols". need_cols should also be a large array. Just find a way to optimize this area.
Try changing it to this

ind = set(i.keys()) & set(need_cols)
temp = {d: i[d] for d in ind}
小葫芦

Ask and answer your own questions

Just change it to a generator

def data_generator(*args):
    for i in v_data:  # v_data是个较大的dict
        temp = {key: value for key, value in i.iteritems() if key in need_cols}  # 部分key不需要
        temp["sid"] = sid  # 单独加一个sid
        yield temp
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template