On Thu, 2009-03-26 at 12:22 -0700, paul.scipi...@aps.com wrote:
> Hello,
>
> I'm a newbie to Python. I have a list which contains integers (about
> 80,000). I want to find a quick way to get the numbers that occur in
> the list more than once, and how many times that number is duplicated
> in t
python that can grab this info without
> looping through a list.
icount = {}
for i in list_of_ints:
icount[i] = icount.get(i, 0) + 1
Now you have a dictionary of every integer in the list and the count of
times it appears.
--
D'Arcy J.M. Cain | Democracy is
Hello,
I'm a newbie to Python. I have a list which contains integers (about 80,000).
I want to find a quick way to get the numbers that occur in the list more than
once, and how many times that number is duplicated in the list. I've done this
right now by looping through the list, getting a
collin wrote:
For example, if I were to have the code
randomlist = ["1", "2", "3", "4"]
And I want to count the distance between strings "1" and "4" which is
3, what command can I use to do this?
--
http://mail.pyth
On Mon, 23 Feb 2009 21:35:21 -0800, collin wrote:
> For example, if I were to have the code
>
> randomlist = ["1", "2", "3", "4"]
>
> And I want to count the distance between strings "1" and "4" which is 3,
> what com
On Feb 23, 9:35 pm, collin wrote:
> For example, if I were to have the code
>
> randomlist = ["1", "2", "3", "4"]
>
> And I want to count the distance between strings "1" and "4" which is
> 3, what command can I use
For example, if I were to have the code
randomlist = ["1", "2", "3", "4"]
And I want to count the distance between strings "1" and "4" which is
3, what command can I use to do this?
--
http://mail.python.org/mailman/listinfo/python-list
In article <3ed253bb-d6ec-4f47-af08-ad193e9c4...@h16g2000yqj.googlegroups.com>,
odeits wrote:
>def count_consecutive(rows):
>switch =3D 0
>count =3D 0
>for r in rows:
>if r[-1] =3D=3D switch:
>count +=3D 1
>else:
>
1r[2],switch
>
> data2_row.append([d1r[0],d1r[1],d1r[2],switch])
>
> HTH,
>
> Emile
def count_consecutive(rows):
switch = 0
count = 0
for r in rows:
if r[-1] == switch:
count += 1
else:
switch = not switch
brianrpsgt1 wrote:
def step1(val):
data2_row = []
for d1r in data1_row:
if d1r[1] >= val:
switch = 0
data2_row = d1r[0],d1r[1],d1r[2],switch
data2_row.append([d1r[0],d1r[1],d1r[2],switch])
HTH,
Emile
--
http://mail.python.org/mailma
I have a list of three columns of data. I run the following code:
def step1(val):
for d1r in data1_row:
if d1r[1] >= val:
switch = 0
data2_row = d1r[0],d1r[1],d1r[2],switch
print d1r[0],d1r[1],d1r[2],switch
else:
switch = 1
upto_1st_closed_parenth[i].count('(')
#expand the pattern to get all of the prototype
#ie upto the last closed parenthesis
#saying something like
pattern = re.compile(\
'match_upto_1st_closed_parenth[i]+\
ompile('\w+::\w+\([^)]*\)')
match_upto_1st_closed_parenth=
re.findall(pattern_upto_1st_closed_parenth,txt)
num_of_protos = len(match_upto_1st_closed_parenth)
for i in range (0,num_of_protos-1):
num_of_open_parenths = match_upto_1st_closed_parenth[i].count('(')
#expand the
> Here you
> are:http://svn.python.org/projects/python/branches/release25-maint/Misc/S...
Excellent, thank you.
--
http://mail.python.org/mailman/listinfo/python-list
darrenr wrote:
Thanks for the quick reply. Could you provide a link to more
information on the debug build you refer to?
Here you are:
http://svn.python.org/projects/python/branches/release25-maint/Misc/SpecialBuilds.txt
--
http://mail.python.org/mailman/listinfo/python-list
darrenr wrote:
Thanks for the quick reply. Could you provide a link to more
information on the debug build you refer to?
A modified version of this algorithm should do the trick for my
purposes, it finds the non-containers that gc ignores. I don't care
how long it takes to compute, I just don't
> Thanks for the quick reply. Could you provide a link to more
> information on the debug build you refer to?
A modified version of this algorithm should do the trick for my
purposes, it finds the non-containers that gc ignores. I don't care
how long it takes to compute, I just don't want the proc
On Nov 6, 7:28 pm, Christian Heimes <[EMAIL PROTECTED]> wrote:
> darrenr wrote:
> > Hello,
>
> > Does anyone know of an efficient way to get a count of the total
> > number of Python objects in CPython? The best solution I've been able
> > to find is len(
darrenr wrote:
Hello,
Does anyone know of an efficient way to get a count of the total
number of Python objects in CPython? The best solution I've been able
to find is len(gc.get_objects()) which unfortunately has to walk a C
linked list *and* creates a list containing all of the objects,
Hello,
Does anyone know of an efficient way to get a count of the total
number of Python objects in CPython? The best solution I've been able
to find is len(gc.get_objects()) which unfortunately has to walk a C
linked list *and* creates a list containing all of the objects, when
all I need
On 2008-10-23 09:26, Gilles Ganault wrote:
> On Thu, 23 Oct 2008 00:24:01 -0200, "Gabriel Genellina"
> <[EMAIL PROTECTED]> wrote:
>> In case you didn't notice, B.D. already provided the answer you're after -
>> reread his 3rd paragraph from the end.
>
> Yes, but it doesn't work with this wrapper
(APSW version 3.5.9-r1):
The recommended way is to pass the arguments to cursor.execute, ie:
I'm getting an error when doing it this way:
===
isbn = "123"
sql = "SELECT COUNT(*) FROM books WHERE isbn='%s'"
#Incorrect number of bindings supplied. The cur
Dennis Lee Bieber wrote:
On Thu, 23 Oct 2008 09:26:54 +0200, Gilles Ganault <[EMAIL PROTECTED]>
declaimed the following in comp.lang.python:
Yes, but it doesn't work with this wrapper (APSW version 3.5.9-r1):
APSW is not, so far as I recall, a "DB-API 2" adapter -- it is a
touch more
wrapper (APSW version 3.5.9-r1):
The recommended way is to pass the arguments to cursor.execute, ie:
I'm getting an error when doing it this way:
===
isbn = "123"
sql = "SELECT COUNT(*) FROM books WHERE isbn='%s'"
#Incorrect number of bindings supplied. The
Gilles Ganault wrote:
Hello
I'm trying to use the APSW package to access a SQLite database, but
can't find how to check if a row exists. I just to read a
tab-separated file, extract a key/value from each line, run "SELECT
COUNT(*)" to check whether this tuple exists in the
3.5.9-r1):
>> The recommended way is to pass the arguments to cursor.execute, ie:
I'm getting an error when doing it this way:
===
isbn = "123"
sql = "SELECT COUNT(*) FROM books WHERE isbn='%s'"
#Incorrect number of bindings supplied. The current stat
api specification, the return
value of cursor.execute is not defined (IOW : can be absolutely
anything).
OK, I'll check if I can find how to get the result from a SELECT
COUNT(*) and if not, use a different wrapper. Thanks a lot for the
embedded comments.
In case you didn't notice
>
> Now I don't know what apsw is, but it's common for libraries
> to provide their own wrapping of the db-api.
>
From the Debian GNU/Linux package manager
APSW (Another Python SQLite Wrapper) is an SQLite 3 wrapper
that provides the thinnest layer over SQLite 3 possi
: can be absolutely
>anything).
OK, I'll check if I can find how to get the result from a SELECT
COUNT(*) and if not, use a different wrapper. Thanks a lot for the
embedded comments.
--
http://mail.python.org/mailman/listinfo/python-list
Gilles Ganault a écrit :
Hello
I'm trying to use the APSW package to access a SQLite database, but
can't find how to check if a row exists. I just to read a
tab-separated file, extract a key/value from each line, run "SELECT
COUNT(*)" to check whether this tuple exists in
Hello
I'm trying to use the APSW package to access a SQLite database, but
can't find how to check if a row exists. I just to read a
tab-separated file, extract a key/value from each line, run "SELECT
COUNT(*)" to check whether this tuple exists in the SQLite database,
and i
On Jul 2, 8:13 pm, Tim Golden <[EMAIL PROTECTED]> wrote:
> In case it helps, there's a recipe just shown up
> on the Python Cookbook which at least illustrates
> DAO use:
>
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/572165
>
> TJG
On Jul 2, 6:30 pm, "M.-A. Lemburg" <[EMAIL PROTECTED
In case it helps, there's a recipe just shown up
on the Python Cookbook which at least illustrates
DAO use:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/572165
TJG
--
http://mail.python.org/mailman/listinfo/python-list
On 2008-07-02 16:54, Iain King wrote:
On Jul 2, 3:29 pm, Tim Golden <[EMAIL PROTECTED]> wrote:
Iain King wrote:
Hi. I'm using the win32 module to access an Access database, but I'm
running into the File Sharing lock count as
inhttp://support.microsoft.com/kb/815281
The solu
Iain King wrote:
On Jul 2, 3:29 pm, Tim Golden <[EMAIL PROTECTED]> wrote:
Iain King wrote:
Hi. I'm using the win32 module to access an Access database, but I'm
running into the File Sharing lock count as
inhttp://support.microsoft.com/kb/815281
The solution I'd like to
On Jul 2, 3:29 pm, Tim Golden <[EMAIL PROTECTED]> wrote:
> Iain King wrote:
> > Hi. I'm using the win32 module to access an Access database, but I'm
> > running into the File Sharing lock count as
> > inhttp://support.microsoft.com/kb/815281
> > The so
Iain King wrote:
Hi. I'm using the win32 module to access an Access database, but I'm
running into the File Sharing lock count as in
http://support.microsoft.com/kb/815281
The solution I'd like to use is the one where you can temporarily
override the setting using (i
Hi. I'm using the win32 module to access an Access database, but I'm
running into the File Sharing lock count as in
http://support.microsoft.com/kb/815281
The solution I'd like to use is the one where you can temporarily
override the setting using (if we were in VB):
DAO.DBE
En Tue, 01 Apr 2008 18:49:28 -0300, Mitko Haralanov <[EMAIL PROTECTED]>
escribió:
> For the most part, I understand the theory behind reference counting in
> Python C code. But there is one thing that I am confused about and I
> have not been able to clear it up.
>
> Let say that you have the fo
For the most part, I understand the theory behind reference counting in
Python C code. But there is one thing that I am confused about and I
have not been able to clear it up.
Let say that you have the following function (over-simplified):
PyObject *do_work (PyObject *self, PyObject *args) {
d'oh!
On 12 mar, 07:58, John Machin <[EMAIL PROTECTED]> wrote:
> On Mar 12, 10:29 pm, Bernard <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hey Larry,
>
> > that one is fairly easy:
>
> > >>> from array import array
> > >>> array
Thanks to all those who replied to this post. I'm gonna try your
suggestions. They are a great help.
--
http://mail.python.org/mailman/listinfo/python-list
On Mar 12, 10:29 pm, Bernard <[EMAIL PROTECTED]> wrote:
> Hey Larry,
>
> that one is fairly easy:
>
> >>> from array import array
> >>> array('i', [1, 2, 3, 4, 5, 1, 2])
> >>> def count(x, arr):
>
> cpt = 0 # declare
Hey Larry,
that one is fairly easy:
>>> from array import array
>>> array('i', [1, 2, 3, 4, 5, 1, 2])
>>> def count(x, arr):
cpt = 0 # declare a counter variable
for el in arr: # for each element in the array
if el == x
On Mar 12, 10:26 am, Larry <[EMAIL PROTECTED]> wrote:
> I'm new to Python. I have a file (an image file actually) that I need
> to read pixel by pixel. It's an 8-bit integer type. I need to get the
> statistics like mean, standard deviation, etc., which I know a little
> bit already from reading nu
Dear all,
I'm new to Python. I have a file (an image file actually) that I need
to read pixel by pixel. It's an 8-bit integer type. I need to get the
statistics like mean, standard deviation, etc., which I know a little
bit already from reading numpy module. What I want to know is how to
get the n
On Dec 27 2007, 5:25 pm, Ian Clark <[EMAIL PROTECTED]> wrote:
> On 2007-12-27, SMALLp <[EMAIL PROTECTED]> wrote:
>
> > connectionString = {"host":"localhost", "user":"root",
> > "passwd":"pofuck", "db":"fileshare"}
> > dataTable = "files"
> > conn = mysql.connect(host=connectionString["host"],
> >
On 2007-12-27, SMALLp <[EMAIL PROTECTED]> wrote:
> connectionString = {"host":"localhost", "user":"root",
> "passwd":"pofuck", "db":"fileshare"}
> dataTable = "files"
> conn = mysql.connect(host=connectionString["host"],
> user=connectionString["user"], passwd=connectionString["passwd"],
> db=conn
uot;:"pofuck", "db":"fileshare"}
> dataTable = "files"
> conn = mysql.connect(host=connectionString["host"],
> user=connectionString["user"], passwd=connectionString["passwd"],
> db=connectionString["db"])
>
> curso
Rob Williscroft wrote:
> SMALLp wrote in news:[EMAIL PROTECTED] in comp.lang.python:
>
>> Hy! I nave another problem I can't solve!
>>
>>
>> import MySQLdb as mysql
>
>> cursor = conn.cursor()
>> sql = "SELECT COUNT(*) FROM " +
SMALLp wrote in news:[EMAIL PROTECTED] in comp.lang.python:
> Hy! I nave another problem I can't solve!
>
>
> import MySQLdb as mysql
> cursor = conn.cursor()
> sql = "SELECT COUNT(*) FROM " + dataTable
> res = cursor.execute(sql)
I think you n
l.connect(host=connectionString["host"],
user=connectionString["user"], passwd=connectionString["passwd"],
db=connectionString["db"])
cursor = conn.cursor()
sql = "SELECT COUNT(*) FROM " + dataTable
res = cursor.execute(sql)
pr
> > > XYZDEFAAcdAA --> XYZ8ADEF2Acd2A
> (RLE), that saved a lot of googles
I have written a rle in my first years in school. It compresses a bitmap
image %50 compression is achivied :) The link :
http://arilaripi.org/index.php?option=com_remository&Itemid=26&func=fileinfo&id=273
And i
On Dec 14, 12:07 pm, "Chris Mellon" <[EMAIL PROTECTED]> wrote:
> On Dec 14, 2007 10:54 AM, nirvana <[EMAIL PROTECTED]> wrote:
>
> > I need to count the number of continous character occurances(more than
> > 1) in a file, and replace it with a compressed vers
On Dec 14, 2007 10:54 AM, nirvana <[EMAIL PROTECTED]> wrote:
> I need to count the number of continous character occurances(more than
> 1) in a file, and replace it with a compressed version, like below
> XYZDEFAAcdAA --> XYZ8ADEF2Acd2A
>
This sounds like homework.
On Fri, 14 Dec 2007 08:54:58 -0800, nirvana wrote:
> I need to count the number of continous character occurances(more than
> 1) in a file, and replace it with a compressed version, like below
> XYZDEFAAcdAA --> XYZ8ADEF2Acd2A
Great. Then go ahead an
I need to count the number of continous character occurances(more than
1) in a file, and replace it with a compressed version, like below
XYZDEFAAcdAA --> XYZ8ADEF2Acd2A
Thanks
Sumod
--
http://mail.python.org/mailman/listinfo/python-list
On 2007-11-27, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> is it possible to parse a pdf file in python? for starters, i would
> like to count the number of pages in a pdf file. i see there is a
> project called ReportLab, but it seems to be a pdf generator... i
> can
Tim Golden wrote:
> [EMAIL PROTECTED] wrote:
>
>> is it possible to parse a pdf file in python? for starters, i would
>> like to count the number of pages in a pdf file. i see there is a
>> project called ReportLab, but it seems to be a pdf generator... i
>> ca
[EMAIL PROTECTED] wrote:
> is it possible to parse a pdf file in python? for starters, i would
> like to count the number of pages in a pdf file. i see there is a
> project called ReportLab, but it seems to be a pdf generator... i
> can't tell if i would be able to
is it possible to parse a pdf file in python? for starters, i would
like to count the number of pages in a pdf file. i see there is a
project called ReportLab, but it seems to be a pdf generator... i
can't tell if i would be able to parse a pdf file programmically.
thanks fo
Beema shafreen wrote:
8< --- file
>my script:
>
>#!/usr/bin/env python
>
>
>fh = open('complete_span','r')
>line = fh.readline().split('#')
>old_probe = line[0].strip()
>old_value = line[1].strip()
= open('complete_span','r')
line = fh.readline().split('#')
old_probe = line[0].strip()
old_value = line[1].strip()
print old_probe, old_value
count = 1
line = ""
while line:
line = fh.readline().strip()
if line :
current_pr
"Dan Bishop" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Oct 24, 8:56 pm, "Junior" <[EMAIL PROTECTED]> wrote:
>> I want to open a text file for reading and delineate it by comma. I also
>> want any data
>> surrounded by
On 10/24/07, Dan Bishop <[EMAIL PROTECTED]> wrote:
>
> On Oct 24, 8:56 pm, "Junior" <[EMAIL PROTECTED]> wrote:
> > I want to open a text file for reading and delineate it by comma. I
> also
> > want any data
> > surrounded by quotation marks th
On Oct 25, 3:56 am, "Junior" <[EMAIL PROTECTED]> wrote:
> I want to open a text file for reading and delineate it by comma. I also
> want any data
> surrounded by quotation marks that has a comma in it, not to count the
> commas inside the
> quotation marks
>
&
On Oct 24, 8:56 pm, "Junior" <[EMAIL PROTECTED]> wrote:
> I want to open a text file for reading and delineate it by comma. I also
> want any data
> surrounded by quotation marks that has a comma in it, not to count the
> commas inside the
> quotation marks
I want to open a text file for reading and delineate it by comma. I also
want any data
surrounded by quotation marks that has a comma in it, not to count the
commas inside the
quotation marks
if the file testfile.txt contains the following;
5,Tuesday,"May is a spring month",Fath
hi all,
which way is the simplest for now to obtain the memory amount eaten by
call to Python 'myfunc' function?
Thx, D
--
http://mail.python.org/mailman/listinfo/python-list
Paul McGuire wrote:
On May 16, 9:02 pm, walterbyrd <[EMAIL PROTECTED]> wrote:
The strings start with whitespace, and have a '*' or an alphanumeric
character. I need to know how many whitespace characters exist at the
beginning of the string.
using buitlin function len() and lstrip()
a
This really is a pretty basic question - to most folks on this list,
it's about the same as "how do I count the fingers on my hand?". Is
this your first Python program? Homework assignment? First program
ever written in any language? Try reading one of the online tutorials
or pic
On May 17, 8:18 am, Steven Howe <[EMAIL PROTECTED]> wrote:
> walterbyrd wrote:
> > I don't know exactly what the first non-space character is. I know the
> > first non-space character will be * or an alphanumeric character.
>
> using builtin function rindex
But only if there is a guarantee that a
and just really learning but this is what I came up
> with.
>
> #!/usr/bin/env python
>
> def main():
> s = " abc def ghi"
> count = 0
>
> for i in s:
> if i == ' ':
> count += 1
> else:
>
On 2007-05-16 20:02:18 -0600, walterbyrd <[EMAIL PROTECTED]> said:
> The strings start with whitespace, and have a '*' or an alphanumeric
> character. I need to know how many whitespace characters exist at the
> beginning of the string.
a = ' three spaces'
print len(a) -len(a.lstrip())
--
http
walterbyrd wrote:
> The strings start with whitespace, and have a '*' or an alphanumeric
> character. I need to know how many whitespace characters exist at the
> beginning of the string.
You really need to stop posting the same message multiple times.
A possible answer using regular expressions:
#!/usr/bin/env python
def main():
s = " abc def ghi"
count = 0
for i in s:
if i == ' ':
count += 1
else:
break
print count
if __name__ == '__main__':
main()
--
Kind Regard
The strings start with whitespace, and have a '*' or an alphanumeric
character. I need to know how many whitespace characters exist at the
beginning of the string.
--
http://mail.python.org/mailman/listinfo/python-list
walterbyrd wrote:
> I don't know exactly what the first non-space character is. I know the
> first non-space character will be * or an alphanumeric character.
>
>
using builtin function rindex
st = 'asblde '
>>> st.rindex(' ')
sph
--
HEX: 09 F9 11 02 9D 74 E3 5B D8 41 56 C5 63 56 88 C0
walterbyrd wrote:
> I don't know exactly what the first non-space character is. I know the
> first non-space character will be * or an alphanumeric character.
>
This is another of the hundreds of ways:
py> for i,c in enumerate(astring):
... if c != ' ': break
...
py> print i
--
http://mail.p
> I don't know exactly what the first non-space character is. I know the
> first non-space character will be * or an alphanumeric character.
How about:
>>> mystring = 'ksjfkfjkfjds '
>>> print len( mystring ) - len( mystring.lstrip( ) )
4
HTH,
Daniel
--
http://mail.python.org/mailman/li
I don't know exactly what the first non-space character is. I know the
first non-space character will be * or an alphanumeric character.
--
http://mail.python.org/mailman/listinfo/python-list
I'm having problems with JPype and am trying to change the way
it creates Python classes as proxies for Java classes and interfaces.
I'm trying to get around "inconsistent mro" problems, but in doing
so, I've run into a real mystery.
Here's the original code. It first makes a metaclass, then makes
> FWIW, the original program can also be compiled with Shed Skin (http://
> mark.dufour.googlepages.com), an experimental (static-)Python-to-C++
> compiler, resulting in a speedup of about 8 times for a single test
> with 500 tuples. here's a slightly modified version that works with
> Shed Skin C
"n00m" <[EMAIL PROTECTED]> writes:
> my dial-up line's too slow for downloading 4mb of shedskin-0.0.20.exe
Don't worry! We can email it to you. :-D
--
Jorge Godoy <[EMAIL PROTECTED]>
--
http://mail.python.org/mailman/listinfo/python-list
>>> RESTART ===
>>>
0
30.4740708665 secs (Anton Vredegoor)
>>> RESTART ===
>>>
0
30.4132625795 secs (Anton Vredegoor)
>>> RESTART ===
>>>
0
30.4812175849 secs (Anton Vredegoor)
>>>
+
my dial-up line's too slow for downloading 4mb of shedskin-0.0.20.exe
--
http://mail.python.org/mailman/listinfo/python-list
bearophileH!
I gave to your "oil" svrl runs ("z in dict" instd of "dict.has_key"
saved only ~0.4 sec).
The result is (and I'm completely lost in all these
*optimizations* :)):
>>> RESTART ===
>>>
0
34.78 secs (bearophileH)
>>> RES
Mark Dufour:
> FWIW, the original program can also be compiled with Shed Skin (http://
> mark.dufour.googlepages.com), an experimental (static-)Python-to-C++
> compiler, resulting in a speedup of about 8 times for a single test
> with 500 tuples.
If we want to play, then this is a literal translat
Paul Rubin wrote:
> "n00m" <[EMAIL PROTECTED]> writes:
> > Two first outputs is of above (your) code; next two - of my code:
>
> Yeah, I see now that we both used the same algorithm. At first glance
> I thought you had done something much slower. The 10 second limit
> they gave looks like they i
[EMAIL PROTECTED] writes:
> for x in e:
> for y in r:
> if -x-y in h:
> sch += h[-x-y]
I wonder whether
g = h.get
for x in e:
for y in r:
if -x-y in h:
sch += g(-x-y, 0)
might be a little bit faster. Also, -x-y
n00m:
> i have no NumPy to test it...
> without Psyco Anton's code is the winner: ~48sec vs ~58sec of my code
> But with Psyco my runtime is ~28sec; Anton's - ~30sec (PC: 1.6 ghz,
> 512 mb)
> Not so bad.. keeping in mind that 256000 billions quadruplets to
> check :)
I have oiled it a bit, you can
i have no NumPy to test it...
without Psyco Anton's code is the winner: ~48sec vs ~58sec of my code
But with Psyco my runtime is ~28sec; Anton's - ~30sec (PC: 1.6 ghz,
512 mb)
Not so bad.. keeping in mind that 256000 billions quadruplets to
check :)
import psyco, time
psyco.full()
t = time.clock(
, dl
cdl = numpy.sort(-(cle + dle))
del cle, dle
# Iterate over arrays, count matching elements
result = 0
i, j = 0, 0
n = n*n
try:
while True:
while abl[i] < cdl[j]:
i +
Steven Bethard <[EMAIL PROTECTED]> writes:
> > According to a post by Raymond Hettinger it's faster to use that
> > iterator instead of `int`.
> Yep. It's because the .next() method takes no arguments, while int()
> takes varargs because you can do:: ...
Heh, good point. Might be worth putting a
Marc 'BlackJack' Rintsch wrote:
> In <[EMAIL PROTECTED]>, Paul Rubin wrote:
>
>> "n00m" <[EMAIL PROTECTED]> writes:
>>> h = collections.defaultdict(itertools.repeat(0).next)
>> Something wrong with
>>h = collections.defaultdict(int)
>> ?
>
> According to a post by Raymond Hettinger it's
n00m wrote:
> 62.5030784639
Maybe this one could save a few seconds, it works best when there are
multiple occurrences of the same value.
A.
from time import time
def freq(L):
D = {}
for x in L:
D[x] = D.get(x,0)+1
return D
def test():
t = time()
f = fil
In <[EMAIL PROTECTED]>, Paul Rubin wrote:
> "n00m" <[EMAIL PROTECTED]> writes:
>> h = collections.defaultdict(itertools.repeat(0).next)
>
> Something wrong with
>h = collections.defaultdict(int)
> ?
According to a post by Raymond Hettinger it's faster to use that iterator
instead of `in
On Mar 16, 12:49 am, "n00m" <[EMAIL PROTECTED]> wrote:
> for o in range(int(f.readline())):
> row = map(int, f.readline().split())
> q.append(row[0])
> w.append(row[1])
> e.append(row[2])
> r.append(row[3])
Does this help at all in reading in your data?
numlines = f.readline()
rows = [
"n00m" <[EMAIL PROTECTED]> writes:
> http://rapidshare.com/files/21267938/m1000.txt
> http://rapidshare.com/files/21268386/m4000.txt
I get 33190970 for the first set and 0 for the second set.
The first set only makes 38853 distinct dictionary entries, I guess
because the numbers are all fairly sm
For those who interested, my test input files:
http://rapidshare.com/files/21267938/m1000.txt
http://rapidshare.com/files/21268386/m4000.txt
--
http://mail.python.org/mailman/listinfo/python-list
301 - 400 of 532 matches
Mail list logo