python 导入excel 速度慢_关于 Python 导出 excel 快慢的问题

body_producer代码

def convert_list(li, datetime_format=consts.china_full_datetime_format,

zone_name=consts.default_zone_name):

out = []

for ele in li:

out.append(ele.to_json(datetime_format,

zone_name=zone_name,

request_handler=None))

return out

def body_producer(page_size=1000):

chunk = []

for ele in query_result:

chunk.append(ele)

if len(chunk) > page_size:

yield from convert_list(chunk)

chunk = []

if chunk:

yield from convert_list(chunk)

profile结果

35238157 function calls (35232213 primitive calls) in 51.559 seconds

Ordered by: cumulative time

ncalls tottime percall cumtime percall filename:lineno(function)

324/1 0.025 0.000 51.559 51.559 {built-in method builtins.exec}

1 1.124 1.124 51.559 51.559 tmp.py:16()

39631 0.113 0.000 27.180 0.001 tmp.py:37(body_producer)

594465 0.856 0.000 15.790 0.000 Worksheet.py:1035(write)

594465 3.486 0.000 14.142 0.000 Row.py:228(write)

1 0.000 0.000 11.857 11.857 peewee.py:6729(__iter__)

1 0.000 0.000 11.857 11.857 peewee.py:1839(inner)

1 0.000 0.000 11.857 11.857 peewee.py:1914(execute)

1 0.000 0.000 11.857 11.857 peewee.py:2085(_execute)

1 0.000 0.000 11.857 11.857 peewee.py:3067(execute)

看样子是是因为peewee的问题,但是感觉xlwt还是慢呀

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值