[Python-Dev] inheriting basic types more efficiently (original) (raw)
Guido van Rossum guido at python.org
Wed Apr 26 23:28:51 CEST 2006
- Previous message: [Python-Dev] inheriting basic types more efficiently
- Next message: [Python-Dev] inheriting basic types more efficiently
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I still don't understand what you are asking for. However there's one problem with your code:
On 4/26/06, Dennis Heuer <dh at triple-media.com> wrote:
class bitarray(long): ... def setitem(self, key, value): [...] long.add(2**key * value) # Should actually overwrite the [...]
What on earth are you trying to do here? There are at least two bugs in this line: (a) long.add is an unbound method so requires two arguments; (b) setitem suggests that you're creating a mutable object; but long is immutable and even if your subclass isn't immutable, it still can't modify the immutable underlying long.
You probably want to write a class that has a long (I agree that it is a good type to implement a bit array) instead of one that is a long. Subclassing is overrated!
I don't understand at all what you're saying about decimal.
You should take this to comp.lang.python; python-dev is about developing Python, not about programming questions.
Even if you believe that your problem can only be solved by changes to Python, I gurantee you that it's much better to discuss this on c.l.py; most likely there's a solution to your problem (once you understand it) that does not involve changing the language or its implementation.
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] inheriting basic types more efficiently
- Next message: [Python-Dev] inheriting basic types more efficiently
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]