Jump to content

script to output every number in a sequence between x and y to a text file


Recommended Posts

Posted

but it takes <20 sec to display the 50000000 it cant possibly iterate them all in that time

 

root@ubuntu:~# time ./test.py

0500000000

 

real 0m13.115s

user 0m12.870s

sys 0m0.020s

 

also >> to a file oinly shows the 1 line

Posted
On this occasion it looks like it's the opposite result. ;)

 

it worked fine for me, in 2min - see the post above

 

did you do: python ./test > output ?

 

I'm using python 2.6

Posted (edited)

Python didn't work for me. Same issue as Rabbie I think. Could be user error though. :(

 

http://i.imgur.com/2D9Yx.png

 

I'm using Python v2.7.3 on Windows 7 (both 64-bit).

 

#!c:/python27/python.exe -u
count = 400000000
while count <= 499999999:
   count = count + 1
print '0%s' % (count)

Edited by Arthur
Posted
Python didn't work for me. Same issue as Rabbie I think. Could be user error though. :(

 

http://i.imgur.com/2D9Yx.png

 

I'm using Python v2.7.3 on Windows 7 (both 64-bit).

 

#!c:/python27/python.exe -u
count = 400000000
while count <= 499999999:
   count = count + 1
print '0%s' % (count)

 

THat's because your script is wrong.

 

Tabs in python are same as brackets. So you've got the print line outside the brackets.

 

Tab it across one and it should print it.

 

e.g.

 

count = 400000000
while count <= 499999999:
   count = count + 1
   print '0%s' % (count)

 

0400000002

>>> ================================ RESTART ================================

>>>

0400000001

0400000002

0400000003

0400000004

0400000005

0400000006

0400000007

0400000008

0400000009

0400000010

0400000011

>>>

etc

 

Steve

  • Thanks 2
Posted
Thanks Steve! It's working now.

 

I blame CyberNerd for not using the proper CODE tags. :D

 

:) Spent many a hour at uni trying to work out why my project wasn't working only to realise it's just pythons stupidty in things like the tabs :(

 

Steve

Posted (edited)
1.2GB text file compresses into a 13MB rar file.. wow.

 

Would be interesting to see the size if it were a Max compressed .arj

Reason being is that I'm scripting some massive folders using 7zip.

Edited by mattx
Posted (edited)
1.2GB text file compresses into a 13MB rar file.. wow.

Would be interesting to see the size if it were a max compressed .arj

Here you are @mattx... :)

 

-------------------------------------------------------
Format                Size (Bytes)     Compression Time
-------------------------------------------------------
PAQ8O (-7)                 612,210             13:53:08
KGB (-a7 -m9)              755,500             03:57:54
ACE                      2,032,579             00:00:45
7-Zip (LZMA*)           11,145,528             00:09:14
7-Zip (LZMA2*)          11,259,540             00:05:12
RAR                     13,429,575             00:00:16
ARC                     14,600,448             00:05:02
XZ                      15,519,312             00:02:33
BZip2                   91,689,039             00:04:49
GZip                   123,841,059             00:08:08
Zip                    123,841,185             00:08:03
7-Zip (PPMd)           161,275,089             00:01:39
LZH                    200,546,065             00:04:33
ARJ (-jm)              220,298,941             00:00:46
PEA                    235,515,251             00:01:28
NTFS                   375,001,088             00:00:13
-------------------------------------------------------
Original:            1,200,000,000             00:03:56 **
-------------------------------------------------------

* Dictionary Size: 96MB / Word Size: 256 / Block Size: 4GB
** Creation time

 

As you can see from the file sizes above, ARJ isn't that great (at least in this particularly case with Rabbie's text file). PAQ, KGB and ACE are the clear winners in terms of size, although 7-Zip is still pretty good epecially when using LZMA2 for the compression method since it can use every processor core in your PC to speed up compression (like WinRAR). ACE has the best file size to compression time ratio, although it could just be extremely good at quickly compressing sequential numbers.

Edited by Arthur
  • Thanks 1
Posted

That's fantastic - the sort of thing I would love to do if I had the time !!

 

Here you are @mattx... :)

 

-------------------------------------------------------
Format                Size (Bytes)     Compression Time
-------------------------------------------------------
PAQ8O (-7)                 612,210             13:53:08
KGB (-a7 -m9)              755,500             03:57:54
ACE                      2,032,579             00:00:45
7-Zip (LZMA*)           11,145,528             00:09:14
7-Zip (LZMA2*)          11,259,540             00:05:12
RAR                     13,429,575             00:00:16
ARC                     14,600,448             00:05:02
XZ                      15,519,312             00:02:33
BZip2                   91,689,039             00:04:49
GZip                   123,841,059             00:08:08
Zip                    123,841,185             00:08:03
7-Zip (PPMd)           161,275,089             00:01:39
LZH                    200,546,065             00:04:33
ARJ (-jm)              220,298,941             00:00:46
PEA                    235,515,251             00:01:28
NTFS                   375,001,088             00:00:13
-------------------------------------------------------
Original:            1,200,000,000             00:03:56 **
-------------------------------------------------------

* Dictionary Size: 96MB / Word Size: 256 / Block Size: 4GB
** Creation time

 

As you can see from the file sizes above, ARJ isn't that great (at least in this particularly case with Rabbie's text file). PAQ, KGB and ACE are the clear winners in terms of size, although 7-Zip is still pretty good epecially when using LZMA2 for the compression method since it can use every processor core in your PC to speed up compression (like WinRAR). ACE has the best file size to compression time ratio, although it could just be extremely good at quickly compressing sequential numbers.

Posted
Originally Posted by Arthur

Only took me 3 minutes 56 seconds.

 

* My PC has a Core i5-2500K @ 4.6GHz, 16GB RAM and a 256GB SSD.

 

out of interest, how long did it take to run the python script on that beast?

 

my work machine managed

real 1m3.992s

user 1m3.080s

sys 0m0.880s

 

on Intel® Core™2 Quad CPU Q6600 @ 2.40GHz

  • Thanks 1
Posted
Now the Geekiness is over, what are you going to do with all those numbers?
Eep, asking about the usage for a large number set is not the geeky bit :)
Posted
Which SSD do you have in your PC?

Crucial M4.

 

out of interest, how long did it take to run the python script on that beast?

I'll run it again when I get home tonight. My old PC had a Q6600 so it will be interesting to see how it compares. :)

Posted (edited)
out of interest, how long did it take to run the python script on that beast? my work machine managed

 

real	1m3.992s
user	1m3.080s
sys	0m0.880s

 

on Intel Core 2 Quad CPU Q6600 @ 2.40GHz

Here's mine...

 

real	0m53.860s
user	0m43.447s
sys	0m0.312s

 

I rebooted into Ubuntu to run your Python script since it was easier. Do you think my times above are what you would expect from a Core i5-2500K + SSD? :confused:

Edited by Arthur
Posted
Here's mine...

 

real	0m53.860s
user	0m43.447s
sys	0m0.312s

 

I rebooted into Ubuntu to run your Python script since it was easier. Do you think my times above are what you would expect from a Core i5-2500K + SSD? :confused:

 

Sounds reasonable, a lot faster than my quad core or dual core machines !

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...