Python syntax in Lisp and Scheme
Alex Martelli
aleax at aleax.it
Sat Oct 4 15:48:54 EDT 2003
Bengt Richter wrote:
...
> I like the Bunch class, but the name suggests vegetables to me ;-)
Well, I _like_ vegetables...
> BTW, care to comment on a couple of close variants of Bunch with
> per-object class dicts? ...
>
> def mkNSC(**kwds): return type('NSC', (), kwds)()
Very nice (apart from the yecchy name;-).
> or, stretching the one line a bit to use the instance dict,
>
> def mkNSO(**kwds): o=type('NSO', (), {})(); o.__dict__.update(kwds);
> return o
I don't see the advantage of explicity using an empty dict and then
updating it with kwds, vs using kwds directly.
> I'm wondering how much space is actually wasted with a throwaway class. Is
> there a lazy copy-on-write kind of optimization for class and instance
> dicts that prevents useless proliferation? I.e.,
I strongly doubt there's any "lazy copy-on-write" anywhere in Python.
The "throwaway class" will be its dict (which, here, you need -- that's
the NS you're wrapping, after all) plus a little bit (several dozen bytes
for the typeobject, I'd imagine); an instance of Bunch, probably a bit
smaller. But if you're going to throw either away soon, who cares?
>>but I think the "purer" (more extreme) versions are
>>interesting "tipizations" for the languages, anyway.
>>
> Oh goody, a new word (for me ;-). Would you define "tipization"?
I thought I was making up a word, and slipped by spelling it
as in Italiano "tipo" rather than English "type". It appears
(from Google) that "typization" IS an existing word (sometimes
mis-spelled as "tipization"), roughly in the meaning I intended
("characterization of types") -- though such a high proportion
of the research papers, institutes, etc, using "typization",
seems to come from Slavic or Baltic countries, that I _am_
left wondering...;-).
Alex
More information about the Python-list
mailing list