summaryrefslogtreecommitdiff
path: root/Objects/methodobject.c
AgeCommit message (Collapse)AuthorLines
2009-07-02only order comparisons are removed in py3k #6119Benjamin Peterson-6/+7
2008-06-09This reverts r63675 based on the discussion in this thread:Gregory P. Smith-6/+6
http://mail.python.org/pipermail/python-dev/2008-June/079988.html Python 2.6 should stick with PyString_* in its codebase. The PyBytes_* names in the spirit of 3.0 are available via a #define only. See the email thread.
2008-05-26Renamed PyString to PyBytesChristian Heimes-6/+6
2008-04-27A little reformating of Py3k warningsBenjamin Peterson-4/+3
2008-04-27Use PyErr_WarnPy3k throughoutBenjamin Peterson-4/+2
2008-03-25Make Py3k warnings consistent w.r.t. punctuation; also respect theGeorg Brandl-9/+8
EOL 80 limit and supply more alternatives in warning messages.
2008-03-21#2346/#2347: add py3k warning for __methods__ and __members__. Patch by Jack ↵Georg Brandl-1/+8
Diederich.
2008-03-18Add py3k warnings for code and method inequality comparisons. This should ↵Steven Bethard-1/+35
resolve issue 2373. The codeobject.c and methodobject.c changes are both just backports of the Python 3 code.
2008-02-14Implemented Martin's suggestion to clear the free lists during the garbage ↵Christian Heimes-2/+11
collection of the highest generation.
2008-02-06Unified naming convention for free lists and their limits. All free listsChristian Heimes-2/+4
in Object/ are named ``free_list``, the counter ``numfree`` and the upper limit is a macro ``PyName_MAXFREELIST`` inside an #ifndef block. The chances should make it easier to adjust Python for platforms with less memory, e.g. mobile phones.
2008-02-06Limit free list of method and builtin function objects to 256 entries each.Christian Heimes-3/+17
2007-11-22Backport of the PCbuild9 directory from the py3k branch.Christian Heimes-1/+1
I've finished the last task for the PCbuild9 directory today. I don't think there is much left to do. Now you can all play around with the shiny new VS 2008 and try the PGO builds. I was able to get a speed improvement of about 10% on py3k. Have fun! :)
2007-07-21PEP 3123: Provide forward compatibility with Python 3.0, while keepingMartin v. Löwis-2/+1
backwards compatibility. Add Py_Refcnt, Py_Type, Py_Size, and PyVarObject_HEAD_INIT.
2006-04-15Use Py_VISIT in all tp_traverse methods, instead of traversing manually orThomas Wouters-11/+2
using a custom, nearly-identical macro. This probably changes how some of these functions are compiled, which may result in fractionally slower (or faster) execution. Considering the nature of traversal, visiting much of the address space in unpredictable patterns, I'd argue the code readability and maintainability is well worth it ;P
2006-02-16Use Py_ssize_t for counts and sizes.Martin v. Löwis-3/+3
Convert Py_ssize_t using PyInt_FromSsize_t
2006-02-15Merge ssize_t branch.Martin v. Löwis-3/+3
2005-12-10Add const to several API functions that take char *.Jeremy Hylton-4/+4
In C++, it's an error to pass a string literal to a char* function without a const_cast(). Rather than require every C++ extension module to put a cast around string literals, fix the API to state the const-ness. I focused on parts of the API where people usually pass literals: PyArg_ParseTuple() and friends, Py_BuildValue(), PyMethodDef, the type slots, etc. Predictably, there were a large set of functions that needed to be fixed as a result of these changes. The most pervasive change was to make the keyword args list passed to PyArg_ParseTupleAndKewords() to be a const char *kwlist[]. One cast was required as a result of the changes: A type object mallocs the memory for its tp_doc slot and later frees it. PyTypeObject says that tp_doc is const char *; but if the type was created by type_new(), we know it is safe to cast to char *.
2003-12-13* Added a new method flag, METH_COEXIST.Raymond Hettinger-1/+1
* Used the flag to optimize set.__contains__(), dict.__contains__(), dict.__getitem__(), and list.__getitem__().
2003-02-18Make __module__ writable except in restricted mode (like for classic classes).Guido van Rossum-1/+1
2003-02-18Make __module__ settable on functions and methods.Jeremy Hylton-1/+1
2003-01-31Provide __module__ attributes for functions defined in C and Python.Jeremy Hylton-6/+40
__module__ is the string name of the module the function was defined in, just like __module__ of classes. In some cases, particularly for C functions, the __module__ may be None. Change PyCFunction_New() from a function to a macro, but keep an unused copy of the function around so that we don't change the binary API. Change pickle's save_global() to use whichmodule() if __module__ is None, but add the __module__ logic to whichmodule() since it might be used outside of pickle.
2003-01-05PyCFunction_Call(): Combined two switch cases w/ identical bodies.Tim Peters-4/+2
2003-01-04SF Patch #661440: Refactor and streamline PyCFunction_CallRaymond Hettinger-31/+41
Refactor code in PyCFunction_Call giving a modest (tiny) speed boost, a slight improvement in semantics (now detects invalid flag combinations), and (arguably) improved clarity (making it blindingly clear which flag combinations are allowed). All this comes at a cost of a few lines of code duplication. * Folded test for METH_KEYWORDS into the switch/case. * Deferred testing for an empty dictionary until when and where needed. * Make a similar deferral for filling the "size" variable. * Inverted the dictionary test so that the common case falls though instead of making a jump.
2002-03-28Introduce two new flag bits that can be set in a PyMethodDef methodFred Drake-1/+1
descriptor, as used for the tp_methods slot of a type. These new flag bits are both optional, and mutually exclusive. Most methods will not use either. These flags are used to create special method types which exist in the same namespace as normal methods without having to use tedious construction code to insert the new special method objects in the type's tp_dict after PyType_Ready() has been called. If METH_CLASS is specified, the method will represent a class method like that returned by the classmethod() built-in. If METH_STATIC is specified, the method will represent a static method like that returned by the staticmethod() built-in. These flags may not be used in the PyMethodDef table for modules since these special method types are not meaningful in that case; a ValueError will be raised if these flags are found in that context.
2002-03-18Re-enable GC of method objects.Neil Schemenauer-7/+6
2001-09-20Add optional docstrings to getset descriptors. Fortunately, there'sGuido van Rossum-1/+1
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.
2001-08-30Removed some unreachable break statements to silence SGI compiler.Sjoerd Mullender-3/+0
2001-08-24repr's converted to using PyString_FromFormat() instead of sprintf'ingBarry Warsaw-8/+6
into a hardcoded char* buffer. Closes patch #454743.
2001-08-16Patch #427190: Implement and use METH_NOARGS and METH_O.Martin v. Löwis-7/+26
2001-08-12Remove much dead code from ceval.cJeremy Hylton-35/+35
The descr changes moved the dispatch for calling objects from call_object() in ceval.c to PyObject_Call() in abstract.c. call_object() and the many functions it used in ceval.c were no longer used, but were not removed. Rename meth_call() as PyCFunction_Call() so that it can be called by the CALL_FUNCTION opcode in ceval.c. Also, fix error message that referred to PyEval_EvalCodeEx() by its old name eval_code2(). (I'll probably refer to it by its old name, too.)
2001-08-02Merge of descr-branch back into trunk.Tim Peters-34/+83
2001-07-12GC for method objects.Neil Schemenauer-11/+31
2000-09-01REMOVED all CWI, CNRI and BeOpen copyright markings.Guido van Rossum-9/+0
This should match the situation in the 1.6b1 tree.
2000-07-09ANSI-fication of the sources.Fred Drake-31/+13
2000-06-30Change copyright notice - 2nd try.Guido van Rossum-6/+0
2000-06-30Change copyright notice.Guido van Rossum-21/+6
2000-06-30Fix an error on AIX by using a proper cast.Guido van Rossum-1/+1
2000-06-30Trent Mick <trentm@activestate.com>:Fred Drake-2/+2
The common technique for printing out a pointer has been to cast to a long and use the "%lx" printf modifier. This is incorrect on Win64 where casting to a long truncates the pointer. The "%p" formatter should be used instead. The problem as stated by Tim: > Unfortunately, the C committee refused to define what %p conversion "looks > like" -- they explicitly allowed it to be implementation-defined. Older > versions of Microsoft C even stuck a colon in the middle of the address (in > the days of segment+offset addressing)! The result is that the hex value of a pointer will maybe/maybe not have a 0x prepended to it. Notes on the patch: There are two main classes of changes: - in the various repr() functions that print out pointers - debugging printf's in the various thread_*.h files (these are why the patch is large) Closes SourceForge patch #100505.
2000-06-29This patch addresses two main issues: (1) There exist some non-fatalFred Drake-2/+8
errors in some of the hash algorithms. For exmaple, in float_hash and complex_hash a certain part of the value is not included in the hash calculation. See Tim's, Guido's, and my discussion of this on python-dev in May under the title "fix float_hash and complex_hash for 64-bit *nix" (2) The hash algorithms that use pointers (e.g. func_hash, code_hash) are universally not correct on Win64 (they assume that sizeof(long) == sizeof(void*)) As well, this patch significantly cleans up the hash code. It adds the two function _Py_HashDouble and _PyHash_VoidPtr that the various hashing routine are changed to use. These help maintain the hash function invariant: (a==b) => (hash(a)==hash(b))) I have added Lib/test/test_hash.py and Lib/test/output/test_hash to test this for some cases.
2000-05-03Vladimir Marangozov's long-awaited malloc restructuring.Guido van Rossum-3/+2
For more comments, read the patches@python.org archives. For documentation read the comments in mymalloc.h and objimpl.h. (This is not exactly what Vladimir posted to the patches list; I've made a few changes, and Vladimir sent me a fix in private email for a problem that only occurs in debug mode. I'm also holding back on his change to main.c, which seems unnecessary to me.)
2000-01-20The rest of the changes by Trent Mick and Dale Nagata for warning-freeGuido van Rossum-1/+1
compilation on NT Alpha. Mostly added casts etc.
1998-12-04When comparing bound methods, use identity test on the objects,Guido van Rossum-1/+1
not equality test.
1998-07-10Marc-Andre Lemburg's patch to move the typedef for PyCFunctionObjectGuido van Rossum-6/+0
to the .h file and add macros there for inlined access to the fields.
1998-06-27New feature: if the object's type has a non-NULL tp_doc field, thatGuido van Rossum-2/+9
is returned as the object's __doc__ attribute. (If only the list of methods would be referenced from the type...)
1997-08-05Added separate free list for cfunction (builtin method) objects, for aGuido van Rossum-7/+30
few percent speed up. Also add PyCFunction_Fini() to discard it.
1997-05-02Quickly renamed the last directory.Guido van Rossum-77/+79
1996-10-25New permission notice, includes CNRI.Guido van Rossum-12/+19
1995-07-26changes for keyword args to built-in functions and classesGuido van Rossum-2/+2
1995-01-26added findmethodinchain and methodchain data typesGuido van Rossum-23/+50
1995-01-10add restrictions in restricted modeGuido van Rossum-1/+7