[Python-Dev] [1.6]: UserList, Dict: Do we need a UserString
class?
Moshe Zadka
Moshe Zadka <mzadka@geocities.com>
Wed, 29 Mar 2000 13:21:09 +0200 (IST)
On Wed, 29 Mar 2000, Peter Funk wrote:
> > 1. I tshouldn't share implementation with UserString, otherwise your
> > algorithm are not behaving with correct big-O properties. It should
> > probably use a char-array (from the array module) as the internal
> > representation.
>
> Hmm.... I don't understand what you mean with 'big-O properties'.
> The internal representation of any object should be considered ...
> umm ... internal.
Yes, but
s[0] = 'a'
Should take O(1) time, not O(len(s))
> > 2. It shouldn't share interface iwth UserString, since it doesn't have a
> > proper implementation with __hash__.
>
> What's wrong with my implementation of __hash__ raising a TypeError with
> the attribution 'unhashable object'.
A subtype shouldn't change contracts of its supertypes. hash() was
implicitly contracted as "raising no exceptions".
--
Moshe Zadka <mzadka@geocities.com>.
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com