Possible to write a Unicode*like* object?
just at xs4all.nl
Tue Feb 4 19:13:57 CET 2003
In article <8cT%9.130771$0v.3716314 at news1.tin.it>,
Alex Martelli <aleax at aleax.it> wrote:
> Just wrote:
> > I'm not sure sure myself, either... I think an example could be: can I
> > write a class (in C) that will be treated just like a unicode object, eg
> > when doing pattern matching with re?
> You can inherit from unicode, of course -- whether that would
> be sufficient for your purpose, I don't know, as it's quite
> possible that modules such as re would bypass your overrides.
I'm afraid I'd then be forced to use the native unicode string storage
(so a downcast actually works), while the main point is that we'd need
custom storage (ie. a pointer to the underlying NSString object). So
once we subclass unicode, we might as well _use_ a unicode object
> > I tend to think we shouldn't even try this and we should simply build a
> > true unicode object, but there are voices in the project that say we
> > should avoid the conversion at all cost. I wouldn't be too unhappy about
> Hmmm, have those other voices read Knuth's ideas about premature
> optimization...? If actual measurements say things are too slow,
> that's another issue, of course.
I agree with you 100%, yet that voice (it's actually mostly one guy ;-)
is a very experienced programmer and has a very deep knowledge of the
system we're interfacing (Objective-C and the Cocoa frameworks) as well
as having extensive experience with other interlanguage bridges. He's
also the project lead ;-) Btw. it's not only performance he's worried
about: he says there are situation where object _identity_ could matter,
which we would break if such an object would be passed to Python and
then back to ObjC. I'm trying to figure out what he means, and whether
it's a _real_ issue and not just a theoretical or very rare one.
More information about the Python-list