removeall() in list

C

castironpi

Nothing else should have direct access to the list.


If the list is not too long, that is reasonable. If it -is- long, the
remove operations can be slow, but that's ok if there's not too many.
If the list is long -and- there's a lot of adds/removes, maybe you
want something like an AVL tree.

But items[ item ]= index is the best I can do in Python.
 
C

castironpi

Well, ok. Nothing else should USE that access.

Ah, very agreed. Access directly at your own risk.

Will you engage with me over e-mail to discuss the Locker
implementation I'm developing? Aaron
 
P

Paul Rubin

Will you engage with me over e-mail to discuss the Locker
implementation I'm developing? Aaron

I really can't, sorry. I'm finding it hard enough to follow over the
newsgroup. If you just have a single one of these lists, it's
probably simplest to do what Frederik Lundh suggested. The other
stuff we've discussed is mostly about how to organize having a lot of
them.
 
C

castironpi

I really can't, sorry. I'm finding it hard enough to follow over the
newsgroup. If you just have a single one of these lists, it's
probably simplest to do what Frederik Lundh suggested. The other
stuff we've discussed is mostly about how to organize having a lot of
them.

Highlight from the working solution:

def onfulfill( self, func, *args, **kwargs ):
'''decorator launches its function in separate thread
upon completion of func. todo: cancel and reference
check.'''
locfunc= Ref()
def honorth():
result= self.op( func, *args, **kwargs )
locfunc.val( result )
def prefulfill( func ):
locfunc.val= func
th= threading.Thread( target= honorth )
th.start()
return prefulfill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top