Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #98696
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Tim Chase <python.list@tim.thechases.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: new to python, help please !! |
| Date | Thu, 12 Nov 2015 05:48:12 -0600 |
| Lines | 34 |
| Message-ID | <mailman.269.1447337476.16136.python-list@python.org> (permalink) |
| References | <93aef8e5-3d6f-41f4-a625-cd3c2007686e@googlegroups.com> <obL0y.222880$6i2.63495@fx35.am4> <5644005e$0$2932$c3e8da3$76491128@news.astraweb.com> <8737wbu49x.fsf@elektro.pacujo.net> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de B0srblkC8C3KveA6C2mpMQKF1024N4SLG7cngGpFns9Q== |
| Return-Path | <python.list@tim.thechases.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.001 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'subject:help': 0.07; 'chunk_size': 0.09; 'chunks': 0.09; 'eof': 0.09; 'subject:python': 0.14; '-tkc': 0.16; '1024': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'md5': 0.16; 'received:10.122': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'true:': 0.16; 'wrote:': 0.16; 'header:In-Reply-To:1': 0.24; 'compare': 0.27; 'large.': 0.29; 'subject:please': 0.35; 'should': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'really': 0.37; 'two': 0.37; 'charset:us-ascii': 0.37; 'wanted': 0.37; 'files': 0.38; 'to:addr:python.org': 0.40; 'skip:n 10': 0.62; 'received:23': 0.84 |
| X-Sender-Id | wwwh|x-authuser|tim@thechases.com |
| X-Sender-Id | wwwh|x-authuser|tim@thechases.com |
| X-MC-Relay | Neutral |
| X-MailChannels-SenderId | wwwh|x-authuser|tim@thechases.com |
| X-MailChannels-Auth-Id | wwwh |
| X-MC-Loop-Signature | 1447328980412:39166612 |
| X-MC-Ingress-Time | 1447328980412 |
| In-Reply-To | <8737wbu49x.fsf@elektro.pacujo.net> |
| X-Mailer | Claws Mail 3.11.1 (GTK+ 2.24.25; x86_64-pc-linux-gnu) |
| X-AuthUser | tim@thechases.com |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:98696 |
Show key headers only | View raw
On 2015-11-12 08:21, Marko Rauhamaa wrote:
> And if you really wanted to compare two files that are known to
> contain MD5 checksums, the simplest way is:
>
> with open('f1.md5') as f1, open('f2.md5') as f2:
> if f1.read() == f2.read():
> ...
> else:
> ...
Though that suffers if the files are large. Might try
CHUNK_SIZE = 4 * 1024 # read 4k chunks
# chunk_offset = 0
with open('f1.md5') as f1, open('f2.md5') as f2:
while True:
c1 = f1.read(CHUNK_SIZE)
c2 = f2.read(CHUNK_SIZE)
if c1 or c2:
# chunk_offset += 1
if c1 != c2:
not_the_same(c1, c2)
# not_the_same(chunk_offset * CHUNK_SIZE, c1, c2)
break
else: # EOF
the_same()
break
which should perform better if the files are huge
-tkc
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
new to python, help please !! Anas Belemlih <anas.belemlih@gmail.com> - 2015-11-11 08:34 -0800
Re: new to python, help please !! John Gordon <gordon@panix.com> - 2015-11-11 16:58 +0000
Re: new to python, help please !! Tim Chase <python.list@tim.thechases.com> - 2015-11-11 11:06 -0600
Re: new to python, help please !! Ben Finney <ben+python@benfinney.id.au> - 2015-11-12 04:16 +1100
Re: new to python, help please !! Quivis <quivis@domain.invalid> - 2015-11-11 17:48 +0000
Re: new to python, help please !! Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-11-12 13:58 +1100
Re: new to python, help please !! Marko Rauhamaa <marko@pacujo.net> - 2015-11-12 08:21 +0200
Re: new to python, help please !! Tim Chase <python.list@tim.thechases.com> - 2015-11-12 05:48 -0600
Re: new to python, help please !! <paul.hermeneutic@gmail.com> - 2015-11-12 07:27 -0700
Re: new to python, help please !! Quivis <quivis@domain.invalid> - 2015-11-12 17:55 +0000
Re: new to python, help please !! Denis McMahon <denismfmcmahon@gmail.com> - 2015-11-12 19:49 +0000
Re: new to python, help please !! Peter Otten <__peter__@web.de> - 2015-11-12 15:56 +0100
Re: new to python, help please !! Tim Chase <python.list@tim.thechases.com> - 2015-11-12 09:00 -0600
Re: new to python, help please !! Peter Otten <__peter__@web.de> - 2015-11-12 16:41 +0100
Re: new to python, help please !! Denis McMahon <denismfmcmahon@gmail.com> - 2015-11-12 21:24 +0000
csiph-web