[Python-Dev] quick poll: could int, str, tuple etc. become type objects?
Donald Beaudry <firstname.lastname@example.org>
Tue, 05 Jun 2001 13:50:34 -0400
Guido van Rossum <email@example.com> wrote,
> Now invoke the Zen of Python: "There should be one-- and preferably
> only one --obvious way to do it." So why not make these built-in
> functions *be* the corresponding types?
I like it!
> but otherwise the behavior would be identical. (Note that I don't
> require that a factory function returns a *new* object each time.)
Of course... singletons (which would also break that requirement) are
> If we did this for all built-in types, we'd have to add maybe a dozen
> new built-in names -- I think that's no big deal and actually helps
> naming types. The types module, with its awkward names and usage, can
> be deprecated.
> There are details to be worked out, e.g.
> - Do we really want to have built-in names for code objects, traceback
> objects, and other figments of Python's internal workings?
I dont think so. Having easy access to these things might be good but
since they are implementation specific it might be best to discourage
their use by putting them somewhere more implementation specific, like
the newmodule or even sys.
> - What should the argument to dict() be? A list of (key, value)
> pairs, a list of alternating keys and values, or something else?
At a minimum, I'd like to see a list of key/value tuples. I seem to
find myself reconstructing dicts from the .items() of other dicts.
For 'something else', I'd like to be able to pass keyword arguments to
initialize the new dict. Going really crazy, I'd like to be able to
pass a dict as an argument to dict()... just another way to spell
copy, but combined with keywords, it would be more like copy followed
by an update.
> - What else?
Well, since you are asking ;) I havnt read the PEP, so perhaps I
shouldnt be commenting just yet, but. I'd hope that the built-in
types are sub-classable from C as well as from Python. This is most
interesting for types like instance, class, method, but I can imagine
reasons for doing it to tuple, list, dict, and even int.
Donald Beaudry Ab Initio Software Corp.
201 Spring Street
firstname.lastname@example.org Lexington, MA 02421
...Will hack for sushi...