On Apr 30, 8:57 pm, n00m <[EMAIL PROTECTED]> wrote:
> >>> a = ['zzz', 'aaa']
> >>> id(a[0]), id(a[1])
>
> (12258848, 12259296)>>> a.sort()
> >>> id(a[0]), id(a[1])
>
> (12259296, 12258848)
>
>
That proves you know nothing, that is a list operation, not a string
operation.
--
http://mail.python.org
>>> a = ['zzz', 'aaa']
>>> id(a[0]), id(a[1])
(12258848, 12259296)
>>> a.sort()
>>> id(a[0]), id(a[1])
(12259296, 12258848)
>>>
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 28, 2:14 am, n00m <[EMAIL PROTECTED]> wrote:
> Lie wrote:
> > On Apr 27, 6:28�am, n00m <[EMAIL PROTECTED]> wrote:
> > > No so simple, guys.
> > > E.g., I can't solve (in Python) this:http://www.spoj.pl/problems/INTEST/
> > > Keep getting TLE (time limit exceeded). Any ideas? After all, it's
On Apr 27, 4:54 pm, n00m <[EMAIL PROTECTED]> wrote:
> Another PC, another OS (Linux) and another compiler C++ (g++ 4.0.0-8)
>
> Compare 2 my latest submissions:http://www.spoj.pl/status/SBANK,zzz/
>
> times: 1.32s and 0.60s
>
> Submitted codes:
>
> import sys
> z=sys.stdin.readlines()
> print z[5]
Another PC, another OS (Linux) and another compiler C++ (g++ 4.0.0-8)
Compare 2 my latest submissions: http://www.spoj.pl/status/SBANK,zzz/
times: 1.32s and 0.60s
Submitted codes:
import sys
z=sys.stdin.readlines()
print z[5]
#include
#include
#include
#include
using namespace std;
vect
Lie wrote:
> On Apr 27, 6:28�am, n00m <[EMAIL PROTECTED]> wrote:
> > No so simple, guys.
> > E.g., I can't solve (in Python) this:http://www.spoj.pl/problems/INTEST/
> > Keep getting TLE (time limit exceeded). Any ideas? After all, it's
> > weekend.
> >
> > 450. Enormous Input Test
> > Problem co
On Apr 27, 6:28 am, n00m <[EMAIL PROTECTED]> wrote:
> No so simple, guys.
> E.g., I can't solve (in Python) this:http://www.spoj.pl/problems/INTEST/
> Keep getting TLE (time limit exceeded). Any ideas? After all, it's
> weekend.
>
> 450. Enormous Input Test
> Problem code: INTEST
>
> The purpose of
Both codes by Dennis Lee Bieber are Ok. The 2nd one ("slurper") ,
seems , a bit faster.
I only corrected the author's typo: should be "% div" instead of "/
div".
And added this (don't know helped it or not):
if div == 1:
print lim
return
And of course:
import psyco
psyco.full()
--
http:
Message -
From: "n00m" <[EMAIL PROTECTED]>
Newsgroups: comp.lang.python
To:
Sent: Sunday, April 27, 2008 6:28 AM
Subject: Re: Python(2.5) reads an input file FASTER than pure C(Mingw)
One more brick.
This time I compare list.sort() vs sort(vector).
Incredible. Python
Have you tried this now?
First try again with pure C code and compile with a C compiler, not
with C++ code and C++ compiler.
Then, tweak the code to use more buffering, to make it more similar
to readline code, like this (not tested):
#include
#include
char vs[1002000][100];
char buffer
Oops... I spotted a slip in my C++ code. Forgot " - t" in
cout << clock()/CLOCKS_PER_SEC << endl;
The correct proportion is 7.5s / 2.75s = 2.7 times.
--
http://mail.python.org/mailman/listinfo/python-list
One more brick.
This time I compare list.sort() vs sort(vector).
Incredible. Python does it by 8.3s / 2.75s = 3 times faster than C++.
import time
f=open('D:\\v.txt','r')
z=f.readlines()
f.close()
t=time.time()
z.sort()
print time.time()-t
m=int(raw_input())
print z[m]
#include
#include
#incl
Dennis Lee Bieber wrote:
> (untested for both):
> -=-=-=-=-=-=-
Many thanks but alas both your codes got "wrong answer" verdict.
I can't understand why; they seem Ok (but I'm a bit sleepy:)).
--
http://mail.python.org/mailman/listinfo/python-list
SL schrieb:
> Is there an implementation of f.readlines on the internet somewhere?
> interested to see in how they implemented it. I'm pretty sure they did
> it smarter than just reserve 100meg of data :)
Of course it is. Checkout the Python sources :)
Christian
--
http://mail.python.org/mailman
Btw seems all accepted pyth solutions (for this prob) used Psyco.
--
http://mail.python.org/mailman/listinfo/python-list
I'm there since summer 2004 :) (with several time breaks)
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 26, 8:28 pm, n00m <[EMAIL PROTECTED]> wrote:
> No so simple, guys.
> E.g., I can't solve (in Python) this:http://www.spoj.pl/problems/INTEST/
> Keep getting TLE (time limit exceeded). Any ideas? After all, it's
> weekend.
>
> 450. Enormous Input Test
> Problem code: INTEST
>
> The purpose of
No so simple, guys.
E.g., I can't solve (in Python) this: http://www.spoj.pl/problems/INTEST/
Keep getting TLE (time limit exceeded). Any ideas? After all, it's
weekend.
450. Enormous Input Test
Problem code: INTEST
The purpose of this problem is to verify whether the method you are
using to rea
On Apr 26, 5:54 pm, n00m <[EMAIL PROTECTED]> wrote:
> hdante:
>
> I run your code quite a few times.
> Its time = 0.734s.
> Of mine = 0.703-0.718s.
>
> PS All I have is an ancient Mingw compiler (~1.9.5v) in Dev-C++.
Okay, now I believe in you. :-P
The next step would be to reimplement readline.
On Apr 26, 12:15 pm, n00m <[EMAIL PROTECTED]> wrote:
> fgets() from C++ iostream library???
Sheesh. That'll teach me to read carefully. (Ok, it probably won't.)
Other two points still apply.
Carl Banks
--
http://mail.python.org/mailman/listinfo/python-list
hdante:
I run your code quite a few times.
Its time = 0.734s.
Of mine = 0.703-0.718s.
PS All I have is an ancient Mingw compiler (~1.9.5v) in Dev-C++.
--
http://mail.python.org/mailman/listinfo/python-list
>> char vs[1002000][99];
In the file 1001622(or so) records like phone number + f/l names.
So the reserving makes sense, i think. Populating of vector
is by zillion times slower.
>> Is there an implementation of f.readlines on the internet somewhere?
I was greatly surprised how fast it is. As a
On Apr 26, 1:15 pm, n00m <[EMAIL PROTECTED]> wrote:
> fgets() from C++ iostream library???
>
fgets is part of the standard C++ library and it lives in the std
namespace.
> I guess if I'd came up with "Python reads SLOWER than C"
> I'd get another (not less) smart explanation "why it's so".
--
ht
On Apr 26, 12:10 pm, n00m <[EMAIL PROTECTED]> wrote:
> Both codes below read the same huge(~35MB) text file.
> In the file > 100 lines, the length of each line < 99 chars.
>
> Stable result:
> Python runs ~0.65s
> C : ~0.70s
>
> Any thoughts?
>
> import time
> t=time.time()
> f=open('D:\\some.t
"SL" <[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]
"n00m" <[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]
using namespace std;
char vs[1002000][99];
if (!fgets(vs[i],999,fp)) break;
BTW why are you declaring the array as 99 and pass 999 to fgets to r
"n00m" <[EMAIL PROTECTED]> schreef in bericht
news:[EMAIL PROTECTED]
import time
t=time.time()
f=open('D:\\some.txt','r')
z=f.readlines()
f.close()
print len(z)
print time.time()-t
m=input()
print z[m]
#include
#include
#include
#include
using namespace std;
char vs[1002000][99];
FILE *f
fgets() from C++ iostream library???
I guess if I'd came up with "Python reads SLOWER than C"
I'd get another (not less) smart explanation "why it's so".
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 26, 11:10 am, n00m <[EMAIL PROTECTED]> wrote:
> Both codes below read the same huge(~35MB) text file.
> In the file > 100 lines, the length of each line < 99 chars.
>
> Stable result:
> Python runs ~0.65s
> C : ~0.70s
>
> Any thoughts?
Yes.
Most of the dirty work in the Python example
Both codes below read the same huge(~35MB) text file.
In the file > 100 lines, the length of each line < 99 chars.
Stable result:
Python runs ~0.65s
C : ~0.70s
Any thoughts?
import time
t=time.time()
f=open('D:\\some.txt','r')
z=f.readlines()
f.close()
print len(z)
print time.time()-t
m=inp
29 matches
Mail list logo