Re: How can I call a subclass method from parent class ?

2005-10-20 Thread Jason Lai
If you use a newstyle class, e.g. class A(object), then you can get the
superclass with cls.__base__. You could also use super(cls,cls),
although note that it returns a  object that isn't exactly the
same thing as a class -- but good enough for just accessing attributes.

Make sure to check that your superclass isn't , otherwise it'll
complain about  not having a foo attribute. __base__ is
probably easier for this purpose. Also be careful with multiple
inheritance.

No such thing as __super though.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C replacement for Queue module

2005-10-21 Thread Jason Lai
How about Python 2.4's collections.deque class? Supposedly it's
thread-safe, and it's implemented in C.

 - Jason

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: C replacement for Queue module

2005-10-22 Thread Jason Lai
As far as Queues go, the adding/popping is apparently done with deque
which are implemented in C. The Queue class pretty much just provides
blocking operations and is otherwise a very thin layer around deque. As
far as primitives go, only threading.Lock is written in C and the
others are pure Python, so they're not that fast, which might be a
reason for Queue's slowness.

As far as writing a custom C module, you could probably leave most of
the work to deque and just implement blocking. If you stick to a simple
lock primative, you can keep it portable and use Python's abstracted
thread interface with an amazing choice of two whole functions: acquire
and release.

-- 
http://mail.python.org/mailman/listinfo/python-list