summaryrefslogtreecommitdiffstats
path: root/Objects/descrobject.c
Commit message (Collapse)AuthorAgeFilesLines
* Added comparison functions to dict proxies.Raymond Hettinger2002-08-311-2/+14
| | | | | Now all non-mutating dict methods are in the proxy also. Inspired by SF bug #602232,
* Make PyDescr_IsData() a macro. It's too simple to be a function.Guido van Rossum2002-08-191-6/+0
| | | | Should save 4% on slot lookups.
* Simple but important optimization for descr_check(): instead of theGuido van Rossum2002-08-191-1/+1
| | | | | | | expensive and overly general PyObject_IsInstance(), call PyObject_TypeCheck() which is a macro that often avoids a call, and if it does make a call, calls the much more efficient PyType_IsSubtype(). This saved 6% on a benchmark for slot lookups.
* Allow more docstrings to be removed during compilationNeal Norwitz2002-08-131-9/+11
|
* SF patch 568629 by Oren Tirosh: types made callable.Guido van Rossum2002-06-141-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These built-in functions are replaced by their (now callable) type: slice() buffer() and these types can also be called (but have no built-in named function named after them) classobj (type name used to be "class") code function instance instancemethod (type name used to be "instance method") The module "new" has been replaced with a small backward compatibility placeholder in Python. A large portion of the patch simply removes the new module from various platform-specific build recipes. The following binary Mac project files still have references to it: Mac/Build/PythonCore.mcp Mac/Build/PythonStandSmall.mcp Mac/Build/PythonStandalone.mcp [I've tweaked the code layout and the doc strings here and there, and added a comment to types.py about StringTypes vs. basestring. --Guido]
* Patch #568124: Add doc string macros.Martin v. Löwis2002-06-131-2/+2
|
* Fold long lines. (Walter, please take note! :-)Guido van Rossum2002-04-131-9/+18
|
* PyObject_GC_Del can now be used as a function designator.Neil Schemenauer2002-04-121-1/+1
|
* Add missing methods iterkeys, itervalues and iteritems toWalter Dörwald2002-03-251-6/+26
| | | | | | dict-proxy objects. Add real docstrings to all methods.
* SF bug #493561: incorrect format string descrobject.c (Neal Norwitz)Guido van Rossum2001-12-151-2/+2
| | | | %300s should be %.300s, twice.
* Well what do you know. The Python implementation contained the sameGuido van Rossum2001-12-101-2/+2
| | | | bug as the C code. :-(
* Fix the Python property class in a comment right.Guido van Rossum2001-12-101-22/+23
|
* property_descr_get(): Fix a curious bug in the property() type: whenGuido van Rossum2001-12-101-5/+5
| | | | | | | | | | no get function was defined, the property's doc string was inaccessible. This was because the test for prop_get was made *before* the test for a NULL/None object argument. Also changed the property class defined in Python in a comment to test for NULL to decide between get and delete; this makes it less Python but then, assigning None to a property doesn't delete it!
* Methods of built-in types now properly check for keyword argumentsGuido van Rossum2001-10-221-0/+11
| | | | | (formerly these were silently ignored). The only built-in methods that take keyword arguments are __call__, __init__ and __new__.
* Adding missing "static" declarations (found by "make smelly").Neil Schemenauer2001-10-211-3/+3
|
* *EXPERIMENTAL* speedup of slot_sq_item. This sped up the followingGuido van Rossum2001-10-031-33/+1
| | | | | | | | | | | | | | | | | | | | | | | test dramatically: class T(tuple): __dynamic__ = 1 t = T(range(1000)) for i in range(1000): tt = tuple(t) The speedup was about 5x compared to the previous state of CVS (1.7 vs. 8.8, in arbitrary time units). But it's still more than twice as slow as as the same test with __dynamic__ = 0 (0.8). I'm not sure that I really want to go through the trouble of this kind of speedup for every slot. Even doing it just for the most popular slots will be a major effort (the new slot_sq_item is 40+ lines, while the old one was one line with a powerful macro -- unfortunately the speedup comes from expanding the macro and doing things in a way specific to the slot signature). An alternative that I'm currently considering is sketched in PLAN.txt: trap setattr on type objects. But this will require keeping track of all derived types using weak references.
* Add Garbage Collection support to new-style classes (not yet to theirGuido van Rossum2001-10-021-20/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | instances). Also added GC support to various auxiliary types: super, property, descriptors, wrappers, dictproxy. (Only type objects have a tp_clear field; the other types are.) One change was necessary to the GC infrastructure. We have statically allocated type objects that don't have a GC header (and can't easily be given one) and heap-allocated type objects that do have a GC header. Giving these different metatypes would be really ugly: I tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new invent a new name for the new metatype and make it a built-in, change affected tests... In short, a mess. So instead, we add a new type slot tp_is_gc, which is a simple Boolean function that determines whether a particular instance has GC headers or not. This slot is only relevant for types that have the (new) GC flag bit set. If the tp_is_gc slot is NULL (by far the most common case), all instances of the type are deemed to have GC headers. This slot is called by the PyObject_IS_GC() macro (which is only used twice, both times in gcmodule.c). I also changed the extern declarations for a bunch of GC-related functions (_PyObject_GC_Del etc.): these always exist but objimpl.h only declared them when WITH_CYCLE_GC was defined, but I needed to be able to reference them without #ifdefs. (When WITH_CYCLE_GC is not defined, they do the same as their non-GC counterparts anyway.)
* Make properties discoverable from Python:Tim Peters2001-09-241-25/+56
| | | | | | | | | | | | | - property() now takes 4 keyword arguments: fget, fset, fdel, doc. Note that the real purpose of the 'f' prefix is to make fdel fit in ('del' is a keyword, so can't used as a keyword argument name). - These map to visible readonly attributes 'fget', 'fset', 'fdel', and '__doc__' in the property object. - fget/fset/fdel weren't discoverable from Python before. - __doc__ is new, and allows to associate a docstring with a property.
* Add optional docstrings to getset descriptors. Fortunately, there'sGuido van Rossum2001-09-201-7/+22
| | | | | | | | | | no backwards compatibility to worry about, so I just pushed the 'closure' struct member to the back -- it's never used in the current code base (I may eliminate it, but that's more work because the getter and setter signatures would have to change.) As examples, I added actual docstrings to the getset attributes of a few types: file.closed, xxsubtype.spamdict.state.
* Add optional docstrings to member descriptors. For backwardsGuido van Rossum2001-09-201-10/+23
| | | | | | | | | | | | | | | compatibility, this required all places where an array of "struct memberlist" structures was declared that is referenced from a type's tp_members slot to change the type of the structure to PyMemberDef; "struct memberlist" is now only used by old code that still calls PyMember_Get/Set. The code in PyObject_GenericGetAttr/SetAttr now calls the new APIs PyMember_GetOne/SetOne, which take a PyMemberDef argument. As examples, I added actual docstrings to the attributes of a few types: file, complex, instance method, super, and xxsubtype.spamlist. Also converted the symtable to new style getattr.
* Rename 'getset' to 'property'.Guido van Rossum2001-09-061-23/+23
|
* Make getset subclassable.Guido van Rossum2001-08-301-1/+1
|
* getset_init(): the function name in the PyArg_ParseTuple() formatGuido van Rossum2001-08-241-1/+1
| | | | should just be "getset", not "getset.__init__".
* repr's converted to using PyString_FromFormat() instead of sprintf'ingBarry Warsaw2001-08-241-10/+8
| | | | | | into a hardcoded char* buffer. Closes patch #454743.
* Change the getset type to take an optional third function argument:Guido van Rossum2001-08-241-9/+21
| | | | | | the delete function. (Question: should the attribute name also be recorded in the getset object? That makes the protocol more work, but may give us better error messages.)
* getset_descr_set(): guard against deletion (indicated by a set callGuido van Rossum2001-08-241-1/+4
| | | | | with a NULL value), in a somewhat lame way: call the set() function with one argument. Should I add a 3rd function, 'del', instead?
* getset_init(): make the arguments optional.Guido van Rossum2001-08-241-3/+11
| | | | getset_doc: add docstring.
* Add new built-in type 'getset' (PyGetSet_Type).Guido van Rossum2001-08-231-0/+135
| | | | This implements the 'getset' class from test_binop.py.
* Patch #427190: Implement and use METH_NOARGS and METH_O.Martin v. Löwis2001-08-161-22/+10
|
* Subtle change to make None.__class__ work:Guido van Rossum2001-08-161-2/+2
| | | | | | | | | - descrobject.c:descr_check(): only believe None means the same as NULL if the type given is None's type. - typeobject.c:wrap_descr_get(): don't "conventiently" default an absent type to the type of the object argument. Let the called function figure it out.
* Merge of descr-branch back into trunk.Tim Peters2001-08-021-0/+854