From: SourceForge.net <no...@so...> - 2007-02-22 02:58:59
|
Patches item #1665693, was opened at 2007-02-21 18:36 Message generated for change (Comment added) made by cgroves You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=312867&aid=1665693&group_id=12867 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: howard kapustein (hsk0) Assigned to: Nobody/Anonymous (nobody) Summary: Optimized types.java Initial Comment: classDictInit() creates identical objects multiple times; this patch precalculates these redundancies: types.java contains patch 1665260 (the patch for [1661679] Invalid types.UnicodeType) typeshkopt.java is the optimized form --- types.java 2007-02-21 09:29:24.581942400 -0500 +++ typeshkpot.java 2007-02-21 09:32:43.356472100 -0500 @@ -13,48 +13,53 @@ // xxx change some of these public static void classDictInit(PyObject dict) { + // Precalculate some reused types + PyObject PyType_PyDictionary = PyType.fromClass(PyDictionary.class); + PyObject PyType_PyFunction = PyType.fromClass(PyFunction.class); + PyObject PyType_PyMethod = PyType.fromClass(PyMethod.class); + PyObject PyType_PyString = PyType.fromClass(PyString.class); + PyObject PyType_PyUnicode = PyType.fromClass(PyUnicode.class); + + // Let's do it... dict.__setitem__("ArrayType", PyType.fromClass(PyArray.class)); dict.__setitem__("BuiltinFunctionType", PyType.fromClass(PyReflectedFunction.class)); dict.__setitem__("BuiltinMethodType", - PyType.fromClass(PyMethod.class)); + PyType_PyMethod); dict.__setitem__("ClassType", PyType.fromClass(PyClass.class)); dict.__setitem__("CodeType", PyType.fromClass(PyCode.class)); dict.__setitem__("ComplexType", PyType.fromClass(PyComplex.class)); - dict.__setitem__("DictType", PyType.fromClass(PyDictionary.class)); - dict.__setitem__("DictionaryType", - PyType.fromClass(PyDictionary.class)); + dict.__setitem__("DictType", PyType_PyDictionary); + dict.__setitem__("DictionaryType", PyType_PyDictionary); dict.__setitem__("EllipsisType", PyType.fromClass(PyEllipsis.class)); dict.__setitem__("FileType", PyType.fromClass(PyFile.class)); dict.__setitem__("FloatType", PyType.fromClass(PyFloat.class)); dict.__setitem__("FrameType", PyType.fromClass(PyFrame.class)); - dict.__setitem__("FunctionType", - PyType.fromClass(PyFunction.class)); + dict.__setitem__("FunctionType", PyType_PyFunction); dict.__setitem__("GeneratorType", PyType.fromClass(PyGenerator.class)); dict.__setitem__("InstanceType", PyType.fromClass(PyInstance.class)); dict.__setitem__("IntType", PyType.fromClass(PyInteger.class)); - dict.__setitem__("LambdaType", PyType.fromClass(PyFunction.class)); + dict.__setitem__("LambdaType", PyType_PyFunction); dict.__setitem__("ListType", PyType.fromClass(PyList.class)); dict.__setitem__("LongType", PyType.fromClass(PyLong.class)); - dict.__setitem__("MethodType", PyType.fromClass(PyMethod.class)); + dict.__setitem__("MethodType", PyType_PyMethod); dict.__setitem__("ModuleType", PyType.fromClass(PyModule.class)); dict.__setitem__("NoneType", PyType.fromClass(PyNone.class)); dict.__setitem__("SliceType", PyType.fromClass(PySlice.class)); - dict.__setitem__("StringType", PyType.fromClass(PyString.class)); + dict.__setitem__("StringType", PyType_PyString); dict.__setitem__("TracebackType", PyType.fromClass(PyTraceback.class)); dict.__setitem__("TupleType", PyType.fromClass(PyTuple.class)); dict.__setitem__("TypeType", PyType.fromClass(PyJavaClass.class)); - dict.__setitem__("UnboundMethodType", - PyType.fromClass(PyMethod.class)); - dict.__setitem__("UnicodeType", PyType.fromClass(PyUnicode.class)); + dict.__setitem__("UnboundMethodType", PyType_PyMethod); + dict.__setitem__("UnicodeType", PyType_PyUnicode); dict.__setitem__("XRangeType", PyType.fromClass(PyXRange.class)); dict.__setitem__("StringTypes", new PyTuple(new PyObject[] { - PyType.fromClass(PyString.class), PyType.fromClass(PyUnicode.class) + PyType_PyString, PyType_PyUnicode })); } } ---------------------------------------------------------------------- >Comment By: Charles Groves (cgroves) Date: 2007-02-21 21:58 Message: Logged In: YES user_id=1174327 Originator: NO Actually, what's the difference between this and http://jython.org/patches/1665263 If this is just a revised version of the first patch, it should just be attached to it. ---------------------------------------------------------------------- Comment By: Charles Groves (cgroves) Date: 2007-02-21 21:56 Message: Logged In: YES user_id=1174327 Originator: NO It's easier to apply and test these things if you attach your patch as a file instead of putting it in your message ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=312867&aid=1665693&group_id=12867 |