Oh well! Just got a flashback from the old times at the 8-bit assembly line.
Dirty deeds done dirt cheap! lol
Date: Sun, 19 May 2013 16:44:55 +0100
From: pyt...@mrabarnett.plus.com
To: python-list@python.org
Subject: Re: How to write fast into a file
On Sun, May 19, 2013 at 3:31 PM, Carlos Nepomuceno
carlosnepomuc...@outlook.com wrote:
Thanks Dan! I've never used CPython or PyPy. Will try them later.
CPython is the classic interpreter, written in C. It's the one
you'll get from the obvious download links on python.org.
ChrisA
--
ooops! I meant to say Cython. nevermind...
Date: Sun, 19 May 2013 19:21:54 +1000
Subject: Re: How to write fast into a file in python?
From: ros...@gmail.com
To: python-list@python.org
On Sun, May 19, 2013 at 3:31 PM, Carlos Nepomuceno
On 19/05/2013 04:53, Carlos Nepomuceno wrote:
Date: Sat, 18 May 2013 22:41:32 -0400
From: da...@davea.name
To: python-list@python.org
Subject: Re: How to write fast into a file in python?
On 05/18/2013 01:00 PM, Carlos Nepomuceno wrote:
Python really
Carlos Nepomuceno carlosnepomuc...@outlook.com wrote:
Python really writes '\n\r' on Windows. Just check the files.
It actually writes \r\n, but it's not Python that's doing it. It's the C
runtime library.
And, of course, you can eliminate all of that by opening the file in binary
mode
On 17 May 2013 19:38, Carlos Nepomuceno carlosnepomuc...@outlook.com
wrote:
Think the following update will make the code more portable:
x += len(line)+len(os.linesep)-1
Not sure if it's the fastest way to achieve that. :/
Putting len(os.linesep)'s value into a local variable will make
Steven D'Aprano於 2013年5月18日星期六UTC+8下午12時01分13秒寫道:
On Fri, 17 May 2013 21:18:15 +0300, Carlos Nepomuceno wrote:
I thought there would be a call to format method by '%d\n' % i. It
seems the % operator is a lot faster than format. I just stopped using
it because I read it was going
On Sat, May 18, 2013 at 5:49 PM, Fábio Santos fabiosantos...@gmail.com wrote:
Putting len(os.linesep)'s value into a local variable will make accessing it
quite a bit faster. But why would you want to do that?
You mentioned \n translating to two lines, but this won't happen. Windows
will not
Python really writes '\n\r' on Windows. Just check the files.
Internal representations only keep '\n' for simplicity, but if you wanna keep
track of the file length you have to take that into account. ;)
Date: Sat, 18 May 2013 08:49:55 +0100
Subject: RE: How
With CPython 2.7.3:
./t
time taken to write a file of size 52428800 is 15.86 seconds
time taken to write a file of size 52428800 is 7.91 seconds
time taken to write a file of size 52428800 is 9.64 seconds
With pypy-1.9:
./t
time taken to write a file of size 52428800 is 3.708232
In article mailman.1813.1368904489.3114.python-l...@python.org,
Dennis Lee Bieber wlfr...@ix.netcom.com wrote:
tOn Sat, 18 May 2013 08:49:55 +0100, Fábio Santos
fabiosantos...@gmail.com declaimed the following in
gmane.comp.python.general:
You mentioned \n translating to two lines, but
On 18 May 2013 20:19, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:
tOn Sat, 18 May 2013 08:49:55 +0100, Fábio Santos
fabiosantos...@gmail.com declaimed the following in
gmane.comp.python.general:
You mentioned \n translating to two lines, but this won't happen. Windows
will not mess
On Sat, 18 May 2013 15:14:31 -0400, Dennis Lee Bieber wrote:
tOn Sat, 18 May 2013 08:49:55 +0100, Fábio Santos
fabiosantos...@gmail.com declaimed the following in
gmane.comp.python.general:
You mentioned \n translating to two lines, but this won't happen.
Windows will not mess with what
On 05/18/2013 01:00 PM, Carlos Nepomuceno wrote:
Python really writes '\n\r' on Windows. Just check the files.
That's backwards. '\r\n' on Windows, IF you omit the b in the mode when
creating the file.
--
DaveA
--
http://mail.python.org/mailman/listinfo/python-list
Date: Sat, 18 May 2013 22:41:32 -0400
From: da...@davea.name
To: python-list@python.org
Subject: Re: How to write fast into a file in python?
On 05/18/2013 01:00 PM, Carlos Nepomuceno wrote:
Python really writes '\n\r' on Windows. Just check the
Thanks Dan! I've never used CPython or PyPy. Will try them later.
I think the main difference between your create_file_numbers_file_like()
and the fastwrite5.py I sent earlier is that I've used cStringIO
instead of StringIO. It took 12s less using cStringIO.
My numbers are much greater, but
BTW, I've downloaded from the following places:
http://stromberg.dnsalias.org/svn/bufsock/trunk/bufsock.py
http://stromberg.dnsalias.org/~dstromberg/backshift/documentation/html/python2x3-pysrc.html
Are those the latest versions?
From:
On 05/17/2013 12:35 AM, lokeshkopp...@gmail.com wrote:
On Friday, May 17, 2013 8:50:26 AM UTC+5:30, lokesh...@gmail.com wrote:
I need to write numbers into a file upto 50mb and it should be fast
can any one help me how to do that?
i had written the following code..
SNIP
value = 0
with
I've got the following results on my desktop PC (Win7/Python2.7.5):
C:\src\Pythonpython -m timeit -cvn3 -r3 execfile('fastwrite2.py')
raw times: 123 126 125
3 loops, best of 3: 41 sec per loop
C:\src\Pythonpython -m timeit -cvn3 -r3 execfile('fastwrite5.py')
raw times: 34 34.3 34
3 loops, best
On Fri, 17 May 2013 18:20:33 +0300, Carlos Nepomuceno wrote:
I've got the following results on my desktop PC (Win7/Python2.7.5):
C:\src\Pythonpython -m timeit -cvn3 -r3 execfile('fastwrite2.py') raw
times: 123 126 125
3 loops, best of 3: 41 sec per loop
Your times here are increased
Thank you Steve! You are totally right!
It takes about 0.2s for the f.write() to return. Certainly because it writes to
the system file cache (~250MB/s).
Using a little bit different approach I've got:
C:\src\Pythonpython -m timeit -cvn3 -r3 -sfrom fastwrite5r import run run()
raw times: 24
On Fri, 17 May 2013 18:20:33 +0300, Carlos Nepomuceno wrote:
### fastwrite5.py ###
import cStringIO
size = 50*1024*1024
value = 0
filename = 'fastwrite5.dat'
x = 0
b = cStringIO.StringIO()
while x size:
line = '{0}\n'.format(value)
b.write(line)
value += 1
x +=
You've hit the bullseye! ;)
Thanks a lot!!!
Oh, I forgot to mention: you have a bug in this function. You're already
including the newline in the len(line), so there is no need to add one.
The result is that you only generate 44MB instead of 50MB.
That's because I'm running on Windows.
Think the following update will make the code more portable:
x += len(line)+len(os.linesep)-1
Not sure if it's the fastest way to achieve that. :/
On Fri, 17 May 2013 18:20:33 +0300, Carlos Nepomuceno wrote:
### fastwrite5.py ###
import cStringIO
size = 50*1024*1024
value = 0
filename =
On Fri, 17 May 2013 21:18:15 +0300, Carlos Nepomuceno wrote:
I thought there would be a call to format method by '%d\n' % i. It
seems the % operator is a lot faster than format. I just stopped using
it because I read it was going to be deprecated. :( Why replace such a
great and fast operator
On Sat, May 18, 2013 at 2:01 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
Consider if x is an arbitrary object, and you call %s % x:
py %s % 23 # works
'23'
py %s % [23, 42] # works
'[23, 42]'
and so on for *almost* any object. But if x is a tuple, strange things
I need to write numbers into a file upto 50mb and it should be fast
can any one help me how to do that?
i had written the following code..
---
def create_file_numbers_old(filename, size):
On Thu, 16 May 2013 20:20:26 -0700, lokeshkoppaka wrote:
I need to write numbers into a file upto 50mb and it should be fast can
any one help me how to do that?
i had written the following code..
--
def
On Friday, May 17, 2013 8:50:26 AM UTC+5:30, lokesh...@gmail.com wrote:
I need to write numbers into a file upto 50mb and it should be fast
can any one help me how to do that?
i had written the following code..
29 matches
Mail list logo