[Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.198,2.198.2.1

Guido van Rossum gvanrossum@users.sourceforge.net
Wed, 06 Jun 2001 10:43:44 -0700


Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv5779

Modified Files:
      Tag: descr-branch
	bltinmodule.c 
Log Message:
A first step towards an idea that received much enthusiasm on
python-dev: instead of having built-in functions list and type, use
the built-in types list and type, whose API has been extended to
accommodate this usage.

Also added object and dictionary (not dict, that's too common a local
variable name).  (For now, the API for dictionary() is undecided.)

Many more will follow in due time(tuple, xrange, str, unicode, int,
long, float, complex, slice, maybe iter, maybe open), but first I need
to get back to doing multiple inheritance right.


Index: bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.198
retrieving revision 2.198.2.1
diff -C2 -r2.198 -r2.198.2.1
*** bltinmodule.c	2001/04/20 19:13:02	2.198
--- bltinmodule.c	2001/06/06 17:43:42	2.198.2.1
***************
*** 1359,1378 ****
  
  static PyObject *
- builtin_list(PyObject *self, PyObject *args)
- {
- 	PyObject *v;
- 
- 	if (!PyArg_ParseTuple(args, "O:list", &v))
- 		return NULL;
- 	return PySequence_List(v);
- }
- 
- static char list_doc[] =
- "list(sequence) -> list\n\
- \n\
- Return a new list whose items are the same as those of the argument sequence.";
- 
- 
- static PyObject *
  builtin_slice(PyObject *self, PyObject *args)
  {
--- 1359,1362 ----
***************
*** 1992,2013 ****
  
  static PyObject *
- builtin_type(PyObject *self, PyObject *args)
- {
- 	PyObject *v;
- 
- 	if (!PyArg_ParseTuple(args, "O:type", &v))
- 		return NULL;
- 	v = (PyObject *)v->ob_type;
- 	Py_INCREF(v);
- 	return v;
- }
- 
- static char type_doc[] =
- "type(object) -> type object\n\
- \n\
- Return the type of the object.";
- 
- 
- static PyObject *
  builtin_vars(PyObject *self, PyObject *args)
  {
--- 1976,1979 ----
***************
*** 2177,2181 ****
  	{"iter",	builtin_iter, 1, iter_doc},
  	{"len",		builtin_len, 1, len_doc},
- 	{"list",	builtin_list, 1, list_doc},
  	{"locals",	builtin_locals, 1, locals_doc},
  	{"long",	builtin_long, 1, long_doc},
--- 2143,2146 ----
***************
*** 2197,2201 ****
  	{"str",		builtin_str, 1, str_doc},
  	{"tuple",	builtin_tuple, 1, tuple_doc},
- 	{"type",	builtin_type, 1, type_doc},
  	{"unicode",	builtin_unicode, 1, unicode_doc},
  	{"unichr",	builtin_unichr, 1, unichr_doc},
--- 2162,2165 ----
***************
*** 2227,2230 ****
--- 2191,2204 ----
  	if (PyDict_SetItemString(dict, "NotImplemented",
  				 Py_NotImplemented) < 0)
+ 		return NULL;
+ 	if (PyDict_SetItemString(dict, "dictionary",
+ 				 (PyObject *) &PyDict_Type) < 0)
+ 		return NULL;
+ 	if (PyDict_SetItemString(dict, "list", (PyObject *) &PyList_Type) < 0)
+ 		return NULL;
+ 	if (PyDict_SetItemString(dict, "object",
+ 				 (PyObject *) &PyBaseObject_Type) < 0)
+ 		return NULL;
+ 	if (PyDict_SetItemString(dict, "type", (PyObject *) &PyType_Type) < 0)
  		return NULL;
  	debug = PyInt_FromLong(Py_OptimizeFlag == 0);