waklin's recent timeline updates
waklin

waklin

V2EX member #136315, joined on 2015-09-01 13:03:54 +08:00
waklin's recent replies
Nov 12, 2015
Replied to a topic by waklin 北京 清河小营安宁里小区 2 居室整租
继续
Nov 12, 2015
Replied to a topic by neone Vim 在 vim 里,大家都是用哪个键来替代 esc 的?
@laoyur 和我一样
Nov 2, 2015
Replied to a topic by kenshinhu 编辑器 从 st3 转到 vim 有什么好的建议?
要管理项目文件, Vim 下用 NERDTree 插件。
Nov 2, 2015
Replied to a topic by MartinWu Python 关于 python 的线程问题
t.start()是异步的并不阻塞当前函数, t.start()完成后,当前线程函就结束了。
Oct 17, 2015
Replied to a topic by yongzhong 程序员 当遇到低谷期的时候该怎么办?
打 lol 吧
Oct 14, 2015
Replied to a topic by raiz Python python 读取二进制文件的速度
1. 你的第一个帖子里提到你处理 5.49M 的文件总共花了 29m ,读到结尾,花了 1850 ms ,如果我理解的没有错,现在你想提高的是 1850ms 的时间
2. 一个 10M 的文件我用我给出的代码的 file.read()到 buff 里,然后遍历 buff 仅花了 50ms 左右,不知道你的 1850ms 是怎么回事
3. BytesIO 和 raw_file 区别
BytesIO 维护的一段内存中的数据, read 的话,仅操作内存
raw_file 相当于一个文件游标, read 的话,是从硬盘上读取
理论上访问硬盘的速度会低于访问内存的速度,但是由于现在硬盘都会有单独的缓存,读取的数据不是很大时,差别不明显。
Oct 14, 2015
Replied to a topic by raiz Python python 读取二进制文件的速度
把 open 的文件换成 1875.wav
Oct 14, 2015
Replied to a topic by raiz Python python 读取二进制文件的速度
你用的二进制方式打开的文件,直接调用 raw_file.read()就已经将文件读入到内存中了。

# -*- coding: utf-8 -*-

import time
if __name__ == '__main__':
with open('TenMiLines-small.csv', 'rb') as raw_file:
start_time = time.time()
buff = raw_file.read()
for b in buff:
# print repr(b)
# b 就是你所说的一个样本
pass
end_time = time.time()
print(' time using: ', (end_time - start_time) * 1000, 'msec')
Oct 14, 2015
Replied to a topic by stupidcat Python 如何在遍历 dict 时改变 dict 的大小?
安装了 chrome 插件,可以在回复中发图片了,测试一下
Oct 14, 2015
Replied to a topic by stupidcat Python 如何在遍历 dict 时改变 dict 的大小?
v2ex 的 python 代码竟然不能缩进!
上面代码运行结果如下

(1, 10)
(2, 20)
(3, 30)
(5, 50)
(7, 70)
{0: 0, 1: 10, 2: 20, 3: 30, 5: 50, 7: 70}

***Repl Closed***
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   830 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 15ms · UTC 20:14 · PVG 04:14 · LAX 13:14 · JFK 16:14
♥ Do have faith in what you're doing.