how abt this ?
N = len(IN)
for k in range(N):
for j in range(N):
if j = k: # or k = j
doSomething()
KM
~~~
On Thu, Sep 18, 2008 at 6:27 PM, Tim Chase [EMAIL PROTECTED]wrote:
Code: Select all
for i in range(len(IN)): #scan all elements of
km wrote:
how abt this ?
N = len(IN)
for k in range(N):
for j in range(N):
if j = k: # or k = j
doSomething()
This has the root problem that the if statement is evaluated
N*N times, which is ugly/slow O(N^2) behavior. My solution
managed to reduce
Steven D'Aprano a écrit :
On Thu, 18 Sep 2008 20:43:00 +0200, Bruno Desthuilliers wrote:
Now the obvious winner is pruebono - even unoptimized, using sets seems
to be *way* faster than even the most optimized corrected version of
your algorithm.
I'm not being snarky about losing priority
Bruno Desthuilliers a écrit :
Alexzive a écrit :
Hello there :) ,
(snip)
Now the obvious winner is pruebono
Correction (my bad) : Steven D'Aprano submitted the set-based solution
first. So the winners are Steven and pruebono.
--
http://mail.python.org/mailman/listinfo/python-list
Harald Luessen a écrit :
On Thu, 18 Sep 2008 Bruno Desthuilliers wrote:
# Harald : uncomment this and run test_results. As far as I can tell, it
# doesn't yields the expected results
## IN7 = IN[:]
## def sortk7(n):
## return n.coordinates[0]
## def doubles7():
## is ordering better
On Sat, 20 Sep 2008 19:01:42 +0200, Bruno Desthuilliers wrote:
Once again, sorry
if me missing your correct answer drives you paranoid :-)
What do you mean by that? How many other people have been talking about
me?
*wink*
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
On Sep 20, 9:20 pm, Steven D'Aprano [EMAIL PROTECTED]
cybersource.com.au wrote:
On Sat, 20 Sep 2008 19:01:42 +0200, Bruno Desthuilliers wrote:
Once again, sorry
if me missing your correct answer drives you paranoid :-)
What do you mean by that? How many other people have been talking about
Thank you all for replying me!
special thanks to Tino. Your code rocks!
I got all the double nodes in couple of seconds
and in a useful output with the coupled nodes pro line..
cheers from Germany!
2008/9/18 Tino Wildenhain [EMAIL PROTECTED]
Tino Wildenhain wrote:
Hi,
En Fri, 19 Sep 2008 02:11:51 -0300, Tino Wildenhain [EMAIL PROTECTED]
escribió:
Also I never saw a list where the threading often goes wrong like
this here - is there any special setup or is it just peoples MUA
which screws up?
Perhaps it's due to the newsgroup/list duality...
--
Gabriel
Bruno Desthuilliers wrote:
Alexzive a écrit :
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.
On Sep 18, 7:42 pm, Steven D'Aprano [EMAIL PROTECTED]
cybersource.com.au wrote:
I'm not being snarky about losing priority here, but I submitted
essentially the same solution two hours earlier than pruebono.
My apologies (seriosuly). In this case, I think it might just be
haste. For what it's
On Thu, 18 Sep 2008 Bruno Desthuilliers wrote:
# Harald : uncomment this and run test_results. As far as I can tell, it
# doesn't yields the expected results
## IN7 = IN[:]
## def sortk7(n):
## return n.coordinates[0]
## def doubles7():
## is ordering better ? - Nope Sir, it's broken...
On Sep 18, 7:42 pm, Steven D'Aprano [EMAIL PROTECTED]
cybersource.com.au wrote:
On Thu, 18 Sep 2008 20:43:00 +0200, Bruno Desthuilliers wrote:
Now the obvious winner is pruebono - even unoptimized, using sets seems
to be *way* faster than even the most optimized corrected version of
your
Gabriel Genellina wrote:
En Fri, 19 Sep 2008 02:11:51 -0300, Tino Wildenhain [EMAIL PROTECTED]
escribió:
Also I never saw a list where the threading often goes wrong like
this here - is there any special setup or is it just peoples MUA
which screws up?
Perhaps it's due to the newsgroup/list
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
Alex Unfortunately my len(IN) is about 100.000 and the running time
Alex about 15h :(
Alex Any idea to improve it?
numpy?
http://numpy.scipy.org/
http://www.scipy.org/Numpy_Example_List
More immediately, note that you are building a list of len(IN) ints every
time
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
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)
Skip:
indexes = range(len(IN))
for i in indexes: #scan all elements of the list IN
for j in indexes:
Nope, use xrange in both situations, and save a list.
Tim Chase:
for i in xrange(len(IN)):
for j in xrange(i+1, len(IN)):
if IN[i].coordinates ==
On Thu, 18 Sep 2008 05:25:02 -0700, 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
Tim Chase:
for i in xrange(len(IN)):
for j in xrange(i+1, len(IN)):
if IN[i].coordinates == IN[j].coordinates:
SN.append(IN[i].label)
If my college algorithms memory serves me sufficiently, this
reduces your O(N^2) to O(N log N) which will garner you some
decent time
On Thu, 2008-09-18 at 07:57 -0500, Tim Chase wrote:
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] ==
On Sep 18, 8:25 am, Alexzive [EMAIL PROTECTED] 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
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
Hi,
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
Tino Wildenhain wrote:
Hi,
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
On Sep 18, 11:18 am, [EMAIL PROTECTED] wrote:
dup=set()
SN=[]
for item in IN:
c=item.coordinates[0], item.coordinates[1]
if c in dup:
SN.append(item.label)
else:
dup.add(c)
+1 for O(N)
If item.coordinates is just an (x, y) pair, you can skip building c
and save a
On Thu, 18 Sep 2008 Alexzive wrote:
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
On Sep 18, 2:25 pm, Alexzive [EMAIL PROTECTED] 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
On Sep 18, 2:25 pm, Alexzive [EMAIL PROTECTED] 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
Harald Luessen a écrit :
(snip)
I did not test the syntax,
but here is an idea with sorted lists.
It should be O(NlogN).
def sk(x):
return x.coordinates[0]
IN.sort(key=sk)
for i in xrange(len(IN)):
for j in xrange(i+1, len(IN)):
if IN[i].coordinates[0] == IN[j].coordinates[0]:
Alexzive a écrit :
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
Bruno Desthuilliers:
def doubles9():
...
SN = []
sn_append = SN.append
Few more:
import psyco
def doubles10():
dup = set()
SN = []
for item in IN:
c = item.coordinates
if c in dup:
SN.append(item)
else:
dup.add(c)
On Thu, 18 Sep 2008 20:43:00 +0200, Bruno Desthuilliers wrote:
Now the obvious winner is pruebono - even unoptimized, using sets seems
to be *way* faster than even the most optimized corrected version of
your algorithm.
I'm not being snarky about losing priority here, but I submitted
bearophile:
doubles12 : 0.00184026840268
For fun, and to have an almost baseline reference, I have done a
little benchmark in D too:
import std.stdio: writefln;
// Using Tango std lib you don't need all this
version (Win32) {
import std.c.windows.windows;
double clock() {
long
Steven D'Aprano wrote:
On Thu, 18 Sep 2008 20:43:00 +0200, Bruno Desthuilliers wrote:
Now the obvious winner is pruebono - even unoptimized, using sets seems
to be *way* faster than even the most optimized corrected version of
your algorithm.
I'm not being snarky about losing priority here,
Hi,
Terry Reedy wrote:
...
Yes, after figuring out what to do from the original post, I saw yours
and then Pruebono's and decided that since two people had submitted the
jackpot algorithm, I need not say more. I will say this: this solution
amounts to finding equivalence classes (the sets of
37 matches
Mail list logo