On Apr 28, 8:54 am, forrest yang wrote:
> i try to load a big file into a dict, which is about 9,000,000 lines,
> something like
> 1 2 3 4
> 2 2 3 4
> 3 4 5 6
>
> code
> for line in open(file)
> arr=line.strip().split('\t')
> dict[arr[0]]=arr
>
> but, the dict is really slow as i load more d
forrest yang a écrit :
i try to load a big file into a dict, which is about 9,000,000 lines,
something like
1 2 3 4
2 2 3 4
3 4 5 6
How "like" is it ?-)
code
for line in open(file)
arr=line.strip().split('\t')
dict[arr[0]]=arr
but, the dict is really slow as i load more data into the m
bearophileh...@lycos.com a écrit :
Sion Arrowsmith:
The keys aren't integers, though, they're strings.
You are right, sorry. I need to add an int() there.
Which is not garanteed to speed up the code FWIW
--
http://mail.python.org/mailman/listinfo/python-list
Sion Arrowsmith:
> The keys aren't integers, though, they're strings.
You are right, sorry. I need to add an int() there.
Bye,
bearophile
--
http://mail.python.org/mailman/listinfo/python-list
prueba...@latinmail.com wrote:
It is probably out of habit of using the generalized idiom:
line="a,b,c\n"
line.strip().split(",")
Ah, thank you. I just couldn't figure out where it started.
--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list
On Apr 29, 1:05 pm, Scott David Daniels wrote:
> Bruno Desthuilliers wrote:
> > d = {}
> > for line in open(thefile):
> > arr = line.strip().split()
> > d[arr[0]] = arr
>
> Sorry, not picking on Bruno in particular, but I keep seeing
> this formulation around various places.
> When does line
Scott David Daniels wrote:
MRAB wrote:
Scott David Daniels wrote:
Bruno Desthuilliers wrote:
d = {}
for line in open(thefile):
arr = line.strip().split()
d[arr[0]] = arr
Sorry, not picking on Bruno in particular, but I keep seeing
this formulation around various places.
When does line.
On Wed, 2009-04-29 at 10:05 -0700, Scott David Daniels wrote:
> Bruno Desthuilliers wrote:
> > d = {}
> > for line in open(thefile):
> >arr = line.strip().split()
> >d[arr[0]] = arr
>
> Sorry, not picking on Bruno in particular, but I keep seeing
> this formulation around various places.
>
MRAB wrote:
Scott David Daniels wrote:
Bruno Desthuilliers wrote:
d = {}
for line in open(thefile):
arr = line.strip().split()
d[arr[0]] = arr
Sorry, not picking on Bruno in particular, but I keep seeing
this formulation around various places.
When does line.strip().split() ever differ
Scott David Daniels wrote:
Bruno Desthuilliers wrote:
d = {}
for line in open(thefile):
arr = line.strip().split()
d[arr[0]] = arr
Sorry, not picking on Bruno in particular, but I keep seeing
this formulation around various places.
When does line.strip().split() ever differ from line.spl
Bruno Desthuilliers wrote:
d = {}
for line in open(thefile):
arr = line.strip().split()
d[arr[0]] = arr
Sorry, not picking on Bruno in particular, but I keep seeing
this formulation around various places.
When does line.strip().split() ever differ from line.split()?
--Scott David Daniels
bearophileh...@lycos.com a écrit :
On Apr 28, 2:54 pm, forrest yang wrote:
i try to load a big file into a dict, which is about 9,000,000 lines,
something like
1 2 3 4
2 2 3 4
3 4 5 6
code
for line in open(file)
arr=line.strip().split('\t')
dict[line.split(None, 1)[0]]=arr
but, the dict
wrote:
>On Apr 28, 2:54 pm, forrest yang wrote:
>> for line in open(file)
>> arr=line.strip().split('\t')
>> dict[line.split(None, 1)[0]]=arr
>
>Keys are integers, so they are very efficiently managed by the dict.
The keys aren't integers, though, they're strings. Though I don't
think tha
On Tue, 28 Apr 2009 10:25:05 -0700, Aahz wrote:
>>but, the dict is really slow as i load more data into the memory, by the
>>way the mac i use have 16G memory. is this cased by the low performace
>>for dict to extend memory or something other reason.
>
> Try gc.disable() before the loop and gc.en
On Apr 28, 2:54 pm, forrest yang wrote:
> i try to load a big file into a dict, which is about 9,000,000 lines,
> something like
> 1 2 3 4
> 2 2 3 4
> 3 4 5 6
>
> code
> for line in open(file)
> arr=line.strip().split('\t')
> dict[line.split(None, 1)[0]]=arr
>
> but, the dict is really slow
In article <7f01f7b7-a561-483a-8e6d-861a8c05f...@p6g2000pre.googlegroups.com>,
forrest yang wrote:
>
>i try to load a big file into a dict, which is about 9,000,000 lines,
>something like
>1 2 3 4
>2 2 3 4
>3 4 5 6
>
>code
>for line in open(file)
> arr=line.strip().split('\t')
> dict[arr[0]]=
16 matches
Mail list logo