[Python-checkins] r46112 - sandbox/trunk/decimal-c/_decimal.c
jack.diederich
python-checkins at python.org
Tue May 23 16:49:57 CEST 2006
Author: jack.diederich
Date: Tue May 23 16:49:56 2006
New Revision: 46112
Modified:
sandbox/trunk/decimal-c/_decimal.c
Log:
* added context_shallow_copy
Modified: sandbox/trunk/decimal-c/_decimal.c
==============================================================================
--- sandbox/trunk/decimal-c/_decimal.c (original)
+++ sandbox/trunk/decimal-c/_decimal.c Tue May 23 16:49:56 2006
@@ -178,6 +178,8 @@
static PyObject *context_new(PyTypeObject *, PyObject *, PyObject *);
static int decimal_nonzero(decimalobject *);
static decimalobject *decimal_copy(decimalobject *);
+static PyObject * py_context_shallow_copy(PyObject *, PyObject *, PyObject *);
+static contextobject * context_shallow_copy(contextobject *);
/* Decimal methods ***********************************************************/
@@ -558,7 +560,7 @@
/* Now rounding starts. We still own "new". */
rnd_func = round_funcs[rounding];
if (prec != ctx->prec) {
- ctx2 = _context_shallow_copy(ctx);
+ ctx2 = (contextobject *)context_shallow_copy(ctx);
if (!ctx2) {
Py_DECREF(new);
return NULL;
@@ -1929,6 +1931,23 @@
return PyInt_FromSsize_t(ETOP(self));
}
+static contextobject *
+context_shallow_copy(contextobject *ctx)
+{
+ contextobject *cp = _new_contextobj(ctx->prec, ctx->rounding,
+ ctx->rounding_dec, ctx->traps,
+ ctx->flags, ctx->Emin, ctx->Emax,
+ ctx->capitals, ctx->clamp,
+ ctx->ignored);
+ return cp;
+}
+
+static PyObject *
+py_context_shallow_copy(PyObject *self, PyObject *args, PyObject *kwds)
+{
+ return (PyObject *)context_shallow_copy((contextobject *)self);
+}
+
CSTUB(abs)
CSTUB(add)
CSTUB(compare)
@@ -2007,6 +2026,8 @@
METH_VARARGS | METH_KEYWORDS},
{"__copy__", (PyCFunction)context_copy,
METH_NOARGS},
+ {"_shallow_copy", (PyCFunction)py_context_shallow_copy,
+ METH_NOARGS},
{NULL, NULL}
};
More information about the Python-checkins
mailing list