Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #44447
| From | Peter Otten <__peter__@web.de> |
|---|---|
| Subject | Re: File Read issue by using module binascii |
| Date | 2013-04-27 14:01 +0200 |
| Organization | None |
| References | <9b5795ab-baec-4c0a-a3b4-1075cffc8744@googlegroups.com> <mailman.1122.1367060234.3114.python-list@python.org> <2441ce7d-8b3a-405f-ab88-d4e772191eb4@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1124.1367064104.3114.python-list@python.org> (permalink) |
Jimmie He wrote:
>> What shell are you using? The one provided by Idle?
>
> Yes. I use IDLE,the python version is 3.3.1.What else could I use??
The shell provided by the operating system is usually much faster. When I
modify your code to
import binascii
def read_bmp():
f = open('example.bmp','rb')
rawdata = f.read() #f.read(1000) is ok
hexstr = binascii.b2a_hex(rawdata) #Get an HEX number
bsstr = bin (int(hexstr,16))[2:]
f.close()
print('bin: ',bsstr,type(bsstr))
return
if __name__ == "__main__":
read_bmp()
and generate a dummy example.bmp with 2**20 (about 1 million) bytes it takes
about 2 seconds to terminate -- on hardware that is quite old. If I redirect
the output it is even faster:
$ time python3 bmp_to_bin.py > /dev/null
real 0m0.766s
user 0m0.300s
sys 0m0.180s
I am a Linux user, but expect similar numbers on Windows (in the DOS box or
one of its successors).
I have considered filing a bug* to ask for a tweak in idle that improves its
responsiveness, but first wanted you to confirm that this was indeed the
problem.
(*) on http://bugs.python.org, if you want to do it yourself
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
File Read issue by using module binascii Jimmie He <jimmie.he@gmail.com> - 2013-04-26 20:57 -0700
Re: File Read issue by using module binascii Jimmie He <jimmie.he@gmail.com> - 2013-04-26 21:22 -0700
Re: File Read issue by using module binascii Fábio Santos <fabiosantosart@gmail.com> - 2013-04-27 10:56 +0100
Re: File Read issue by using module binascii Jimmie He <jimmie.he@gmail.com> - 2013-04-27 03:42 -0700
Re: File Read issue by using module binascii Peter Otten <__peter__@web.de> - 2013-04-27 12:57 +0200
Re: File Read issue by using module binascii Jimmie He <jimmie.he@gmail.com> - 2013-04-27 04:23 -0700
Re: File Read issue by using module binascii Fábio Santos <fabiosantosart@gmail.com> - 2013-04-27 12:40 +0100
Re: File Read issue by using module binascii Peter Otten <__peter__@web.de> - 2013-04-27 14:01 +0200
Re: File Read issue by using module binascii Jimmie He <jimmie.he@gmail.com> - 2013-04-27 05:46 -0700
Re: File Read issue by using module binascii Tim Roberts <timr@probo.com> - 2013-04-27 21:34 -0700
Re: File Read issue by using module binascii Peter Otten <__peter__@web.de> - 2013-04-28 09:42 +0200
Re: File Read issue by using module binascii jt@toerring.de (Jens Thoms Toerring) - 2013-04-28 12:04 +0000
Re: File Read issue by using module binascii Jimmie He <jimmie.he@gmail.com> - 2013-04-28 06:32 -0700
csiph-web