Forum Moderators: Lobo3433, Staff Forum Coordinators: Anim8dtoon
Poser Python Scripting F.A.Q (Last Updated: 2026 Mar 27 4:38 pm)
Because Python is an interpreter, it has to check the types of both parameters for every myVectors[vec[0]] = vec[1]
Doing typechecking 20000 times needs time. This is the reason why numeric should be used if computations with values stored in arrays are needed. Sometimes it may be required to change program logic to be able to use numeric.
Numeric is a built-in package with Poser Python, but a lower version.
Curious. There must be more to this than you told us. Unless you define "ages" to be 4.5 milliseconds, I'm very confused by your results. The following script sets up a 20000 element array of sets that are to be performed on the target array. It measures the time it takes to do the sets, and in Poser 6 on my PC it averages about 4.5 milliseconds.
I did one tiny optimization, which is to have the "for" loop break the set up already using tuple assignment so I don't have to do the subscripting of vec[0] and vec[1].
# make 20000 copies of [0, [1,2,3]]
sets = [[0, [1,2,3]]] * 20000
# make a 30000 element array
target = [None] * 30000
# get access to hi-res timer
from time import clock
# function to do the test
def test(a, b):
# get current time
t = clock()
for v0,v1 in a:
b[v0] = v1
# calculate delta time
t = clock() - t
# print time (in milliseconds)
print t * 1000
test(sets, target)
Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)
Just for completeness, I changed the loop back to the way you did it.
for v in a:
b[v[0]] = v[1]
This runs in about 5.5 milliseconds, so the two subscripts are adding about 20% to the cost.
Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)
This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.
Hi there. I have 2 lists with 30000 and 20000 elements. Every element in 1st list named myVectors looks like this [x,y,z], in second list named newVectors every element looks like this [index,[x,y,z]]. Is there a more efficient (faster) way to do this:
for vec in newVectors:
**myVectors[vec[0]] = vec[1]
**This is too slow and it takes ages to process all 20000 elements.