Least used builtins?
Ian Bicking
ianb at colorstudy.com
Fri Jul 4 16:50:50 EDT 2003
While I agree some of the math stuff need not be in builtins, in most
case I think the things in builtins are reasonable. Except of course
for functions that are essentially deprecated, or have become redundant.
On Fri, 2003-07-04 at 15:00, Lulu of the Lotus-Eaters wrote:
> To the top of a module/script. Some quick thoughts:
>
> Current builtin Possible Home
> --------------- ---------------
> abs math
> apply functional
> basestring internal
> bool
> buffer
> callable sys
callable is a little funny, and not hugely useful, but sys isn't really
appropriate.
> chr
> classmethod new
Ick, no. classmethod, as well as staticmethod and property, are *meant*
to be builtins. They are idiomatic, there's no reason they should
appear in a module. There's no reason something named "classmethod"
should ever show up in another module, for instance. Every programmer
needs to know what classmethod is -- hiding it won't reduce the amount
of things a programmer needs to know.
> cmp
> coerce
> compile code
> complex math
It makes sense, but I also would like to have the basic constructors and
types available as builtins.
> delattr
> dict
> dir
> divmod math
> enumerate itertools
Again, this is idiomatic, and it belongs in builtins.
> eval code
> execfile code
> file
> filter functional
Only because it's become redundant.
> float
> getattr
> globals
> hasattr
> hash internal
> hex math
> id internal
> input
> int
> intern internal
> isinstance sys
> issubclass sys
Definitely not -- these are very important, importing them would be
obnoxious. Especially since "isinstance(value, str)" is the preferred
technique over "type(value) is str".
> iter
> len
> list
> locals
> long
> map functional
> max math
> min math
> object internal
Eh? That's just silly! If you are doing OO using 2.2 features you will
always end up importing this.
> oct math
> open
> ord
> pow math
> property new
> range
> raw_input
> reduce functinal
> reload
> repr
> round math
> setattr
> slice
> staticmethod new
> str
> super internal
Again, highly idiomatic, programmers should be discouraged from using
this name for anything else, and it needs to be available to encourage
the use of this new feature.
> tuple
> type
> unichr
> unicode
> vars
> xrange itertools
> zip itertools
zip, like enumerate, is idiomatic -- importing it does not imply
anything about your code, that it comes from itertools lends little
insight into what zip does.
Of course, this is all academic, as reducing builtins would cause
backward compatibility issues, while providing no real advantages.
Ian
More information about the Python-list
mailing list