[issue17436] pass a file object to hashlib.update

2013-03-17 Thread STINNER Victor
STINNER Victor added the comment: > obj.update(buffer[:size]) This code does an useless memory copy: obj.update(memoryview(buffer)[:size]) can be used instead. -- ___ Python tracker __

[issue17436] pass a file object to hashlib.update

2013-03-16 Thread anatoly techtonik
anatoly techtonik added the comment: I don't get that. I thought that buffered reading should be faster, although I agree that OS should handle this better. Why have the buffering turned on by default then? (I miss the ability to fork discussions from tracker, but there is no choice). ---

[issue17436] pass a file object to hashlib.update

2013-03-16 Thread STINNER Victor
STINNER Victor added the comment: > Why unbuffered will be faster?? Well, I'm not sure that it is faster. But I would prefer to avoid buffering if it is not needed. 2013/3/16 anatoly techtonik : > > anatoly techtonik added the comment: > > Why unbuffered will be faster?? > > -- > >

[issue17436] pass a file object to hashlib.update

2013-03-16 Thread anatoly techtonik
anatoly techtonik added the comment: Even though I mentioned passing file object in the title of this bugreport, what I really need is the following API: hexhash = hashlib.sha256().readfile(filename).hexdigest() -- ___ Python tracker

[issue17436] pass a file object to hashlib.update

2013-03-16 Thread anatoly techtonik
anatoly techtonik added the comment: Why unbuffered will be faster?? -- ___ Python tracker ___ ___ Python-bugs-list mailing list Unsub

[issue17436] pass a file object to hashlib.update

2013-03-16 Thread Jesús Cea Avión
Changes by Jesús Cea Avión : -- nosy: +jcea ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.

[issue17436] pass a file object to hashlib.update

2013-03-16 Thread STINNER Victor
STINNER Victor added the comment: > It makes sense to allow hashlib.update accept file like object > to read from. Not update directly, but I agree that an helper would be convinient. Here is another proposition using unbuffered file and readinto() with bytearray. It should be faster, but I di

[issue17436] pass a file object to hashlib.update

2013-03-16 Thread anatoly techtonik
anatoly techtonik added the comment: Otherwise you need to repeat this code. def filehash(filepath): blocksize = 64*1024 sha = hashlib.sha256() with open(filepath, 'rb') as fp: while True: data = fp.read(blocksize) if not data: break

[issue17436] pass a file object to hashlib.update

2013-03-16 Thread anatoly techtonik
Changes by anatoly techtonik : -- title: pass a string to hashlib.update -> pass a file object to hashlib.update ___ Python tracker ___ __