Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Help on slow attribute copy

Reply
Thread Tools

Help on slow attribute copy

 
 
wout
Guest
Posts: n/a
 
      05-18-2005
Hi there,

I am fairly new to python, the problem is as follows:

newnodes = {}
for i in nodes:
newnodes[i.label] = i.coordinate

is very slow, which is due to the dots, I know that for functions the
dot lookup
can be done outside the loop, can this be done for attributes in any
way? (in such a way that it is fast)
Coordinate is a tuple in this case, filling a dictionary of that size is
no problem without dots.
I use python 2.0 as shipped with abaqus, there are about 100000 nodes
in the current case, and more to come, and the
system can be stuck on this for 15+ minutes

Greetings
Wout







This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

 
Reply With Quote
 
 
 
 
bgs
Guest
Posts: n/a
 
      05-18-2005
There's no way that loop takes fifteen minutes just because of the dot
operator. I mean, 200000 dots in 15 minutes is 200 dots/second. On a
1 GHz machine, that would be 5 million cycles per dot. That does not
seem reasonable (assuming you haven't overridden the dot operator to do
something more complicated than normal).

Check that i.label does not have __hash__ overridden in a bad way. I
tried a test case with __hash__ overridden to always return the same
integer, and I got performance about what you are describing when I
tried your example loop with 100000 iterations.

And, of course, make sure you are not low on memory and relying too
heavily on swap space.

 
Reply With Quote
 
 
 
 
wout
Guest
Posts: n/a
 
      05-18-2005
bgs wrote:

>There's no way that loop takes fifteen minutes just because of the dot
>operator. I mean, 200000 dots in 15 minutes is 200 dots/second. On a
>1 GHz machine, that would be 5 million cycles per dot. That does not
>seem reasonable (assuming you haven't overridden the dot operator to do
>something more complicated than normal).
>
>Check that i.label does not have __hash__ overridden in a bad way. I
>tried a test case with __hash__ overridden to always return the same
>integer, and I got performance about what you are describing when I
>tried your example loop with 100000 iterations.
>
>And, of course, make sure you are not low on memory and relying too
>heavily on swap space.
>
>
>

bgs,
thanks for the quick reply
I don't think it's due to the .label, maybe too, but when I take it out
it is still slow (due to the .coordinate)
here's the abaqus stuff:
>>> print mdb.model['Model-1'].rootAssembly.instance['blok'].nodes[1]

({'coordinate': (3.01000022888184, 5.01000022888184, 0.53123539686203),
'coordinates': (3.01000022888184, 5.01000022888184, 0.53123539686203),
'instanceName': 'blok', 'label': 2})
>>> nodes = mdb.model['Model-1'].rootAssembly.instance['blok'].node
>>> for i in nodes:

.... dummy = i.coordinate
wait for half an hour....
The machine is p4 with 1GB ram so should be ok,
running fedora 3

Thanks
Wout

This message has been checked for viruses but the contents of an attachment
may still contain software viruses, which could damage your computer system:
you are advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.

 
Reply With Quote
 
bgs
Guest
Posts: n/a
 
      05-19-2005
Hmm, it looks like the dot operator has been overloaded to do something
complicated. (although if you haven't already, try "for i in nodes:
pass" just to make sure). Is it retrieving the data from the network
somewhere? If so, then it looks like it is probably retrieving each
coordinate individually on each iteration of the loop. Perhaps there
is some way of retrieving them all in one bunch?

It's difficult to say more without knowing anything about abaqus and
its interface.

 
Reply With Quote
 
wout
Guest
Posts: n/a
 
      05-19-2005
bgs wrote:

>Hmm, it looks like the dot operator has been overloaded to do something
>complicated. (although if you haven't already, try "for i in nodes:
>pass" just to make sure). Is it retrieving the data from the network
>
>

I tried that (the pass), that runs fast as it should

>somewhere? If so, then it looks like it is probably retrieving each
>coordinate individually on each iteration of the loop. Perhaps there
>is some way of retrieving them all in one bunch?
>
>

I guess it is looking up the node locations from the database with
individual queries. As the source for the interface is not provided
(only pyc) I will not find out.

>It's difficult to say more without knowing anything about abaqus and
>its interface.
>

I'll look for a 'heap lookup', otherwise I'll have to do text parsing...
Thanks loads anyway
Wout
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: slow slow slow! Expert lino fitter Computer Support 5 12-12-2008 04:00 PM
Re: slow slow slow! General Patron Computer Support 0 12-11-2008 11:01 PM
Re: slow slow slow! chuckcar Computer Support 0 12-10-2008 11:25 PM
Re: slow slow slow! Beauregard T. Shagnasty Computer Support 2 12-10-2008 09:03 PM
Re: slow slow slow! Expert lino fitter Computer Support 0 12-10-2008 02:33 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57