improving a huge double-for cycle
Jake Anderson
jake at vapourforge.com
Thu Sep 18 11:42:45 EDT 2008
psyco might help a fair bit (10x-40x) here ;->
perhaps look at dumping the data into sqlite then pulling it back out.
It (or the other databases) are designed for tossing around large lumps
of data.
Alexzive wrote:
> Hello there :) ,
>
> I am a python newbie and need to run following code for a task in an
> external simulation programm called "Abaqus" which makes use of python
> to access the mesh (ensamble of nodes with xy coordinates) of a
> certain geometrical model.
>
> [IN is the starting input containing the nodes to be check, there are
> some double nodes with the same x and y coordinates which need to be
> removed. SN is the output containing such double nodes]
>
> Code: Select all
> for i in range(len(IN)): #scan all elements of the list IN
> for j in range(len(IN)):
> if i <> j:
> if IN[i].coordinates[0] == IN[j].coordinates[0]:
> if IN[i].coordinates[1] == IN[j].coordinates[1]:
> SN.append(IN[i].label)
>
>
>
> Unfortunately my len(IN) is about 100.000 and the running time about
> 15h !!!! :(
>
> Any idea to improve it?
>
> I have already tried to group the "if statements" in a single one:
>
> Code: Select all
> if i <> j and if IN[i].coordinates[0] == IN[j].coordinates[0] and
> if IN[i].coordinates[1] == IN[j].coordinates[1]:
>
>
> but no improvements.
>
> Many thanks, Alex
> --
> http://mail.python.org/mailman/listinfo/python-list
>
--
Vapour Forge
Jake Anderson
Project Manager
Mobile: 0412 897 125
Email: jake at vapourforge.com
Web Page: www.vapourforge.com
Your source for custom IT services
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080919/9004a651/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: vf.gif
Type: image/gif
Size: 1484 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20080919/9004a651/attachment-0001.gif>
More information about the Python-list
mailing list