Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Right-click on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Samuele Pedroni <pedronis@st...> - 2006-07-20 21:46:15
|
Samuele Pedroni wrote: it's even buggy. HEAPTYPE should not be set by default, only if there's no underlying_class. |
From: Samuele Pedroni <pedronis@st...> - 2006-07-20 21:41:24
|
m_small@... wrote: > Revision: 2853 > Author: m_small > Date: 2006-07-20 14:34:24 -0700 (Thu, 20 Jul 2006) > ViewCVS: http://svn.sourceforge.net/jython/?rev=2853&view=rev > > Log Message: > ----------- > basic support for __flags__ in PyType this doesn't look much basic too me. Any particular reason to do more than support the flag settings used by pickle. This __flags__ are really an implementationd detail of CPython, is kind of unfortunate that pickle.py depends on them, but I don't see the point of doing more than satisfying the minimal requirements, this is what I would do and PyPy does. Notice that the less code the better. > > Modified Paths: > -------------- > branches/2.3/src/org/python/core/Py.java > branches/2.3/src/org/python/core/PySystemState.java > branches/2.3/src/org/python/core/PyType.java > branches/2.3/src/templates/type.expose > Modified: branches/2.3/src/org/python/core/Py.java > =================================================================== > --- branches/2.3/src/org/python/core/Py.java 2006-07-20 12:39:44 UTC (rev 2852) > +++ branches/2.3/src/org/python/core/Py.java 2006-07-20 21:34:24 UTC (rev 2853) > @@ -76,6 +76,59 @@ > /** A Python string containing ' ' **/ > public static PyString Space; > > + /** PyBufferProcs contains bf_getcharbuffer */ > + public static long TPFLAGS_HAVE_GETCHARBUFFER; > + > + /** PySequenceMethods contains sq_contains */ > + public static long TPFLAGS_HAVE_SEQUENCE_IN; > + > + /** This is here for backwards compatibility. Extensions that use the old > + * GC API will still compile but the objects will not be tracked by the > + * GC. */ > + public static long TPFLAGS_GC; > + > + /** PySequenceMethods and PyNumberMethods contain in-place operators */ > + public static long TPFLAGS_HAVE_INPLACEOPS; > + > + /** PyNumberMethods do their own coercion */ > + public static long TPFLAGS_CHECKTYPES; > + > + /** tp_richcompare is defined */ > + public static long TPFLAGS_HAVE_RICHCOMPARE; > + > + /** Objects which are weakly referencable if their tp_weaklistoffset is > + * >0 > + */ > + public static long TPFLAGS_HAVE_WEAKREFS; > + > + /** tp_iter is defined */ > + public static long TPFLAGS_HAVE_ITER; > + > + /** New members introduced by Python 2.2 exist */ > + public static long TPFLAGS_HAVE_CLASS; > + > + /** Set if the type object is dynamically allocated */ > + public static long TPFLAGS_HEAPTYPE; > + > + /** Set if the type allows subclassing */ > + public static long TPFLAGS_BASETYPE; > + > + /** Set if the type is 'ready' -- fully initialized */ > + public static long TPFLAGS_READY; > + > + /** Set while the type is being 'readied', to prevent recursive ready calls > + */ > + public static long TPFLAGS_READYING; > + > + /** Objects support garbage collection (see objimp.h) */ > + public static long TPFLAGS_HAVE_GC; > + > + /** These two bits are preserved for Stackless Python, next after this is > + * 16 */ > + public static long TPFLAGS_HAVE_STACKLESS_EXTENSION; > + > + public static long TPFLAGS_DEFAULT; > + > /** A unique object to indicate no conversion is possible > in __tojava__ methods **/ > public static Object NoConversion; > > Modified: branches/2.3/src/org/python/core/PySystemState.java > =================================================================== > --- branches/2.3/src/org/python/core/PySystemState.java 2006-07-20 12:39:44 UTC (rev 2852) > +++ branches/2.3/src/org/python/core/PySystemState.java 2006-07-20 21:34:24 UTC (rev 2853) > @@ -443,6 +443,33 @@ > Py.EmptyString = new PyString(""); > Py.Newline = new PyString("\n"); > Py.Space = new PyString(" "); > + > + Py.TPFLAGS_HAVE_GETCHARBUFFER = (1L<<0); > + Py.TPFLAGS_HAVE_SEQUENCE_IN = (1L<<1); > + Py.TPFLAGS_GC = 0; /* used to be (1L<<2) */ > + Py.TPFLAGS_HAVE_INPLACEOPS = (1L<<3); > + Py.TPFLAGS_CHECKTYPES = (1L<<4); > + Py.TPFLAGS_HAVE_RICHCOMPARE = (1L<<5); > + Py.TPFLAGS_HAVE_WEAKREFS = (1L<<6); > + Py.TPFLAGS_HAVE_ITER = (1L<<7); > + Py.TPFLAGS_HAVE_CLASS = (1L<<8); > + Py.TPFLAGS_HEAPTYPE = (1L<<9); > + Py.TPFLAGS_BASETYPE = (1L<<10); > + Py.TPFLAGS_READY = (1L<<12); > + Py.TPFLAGS_READYING = (1L<<13); > + Py.TPFLAGS_HAVE_GC = (1L<<14); > + Py.TPFLAGS_HAVE_STACKLESS_EXTENSION = 0; /* if stackless, then (3L<<15); */ > + Py.TPFLAGS_DEFAULT = ( Py.TPFLAGS_HAVE_GETCHARBUFFER | > + Py.TPFLAGS_HAVE_SEQUENCE_IN | > + Py.TPFLAGS_HAVE_INPLACEOPS | > + Py.TPFLAGS_HAVE_RICHCOMPARE | > + Py.TPFLAGS_HAVE_WEAKREFS | > + Py.TPFLAGS_HAVE_ITER | > + Py.TPFLAGS_HAVE_CLASS | > + Py.TPFLAGS_HAVE_STACKLESS_EXTENSION | > + 0); > + > + > // xxx what to do about modules > __builtin__class = PyJavaClass.lookup(__builtin__.class); > > > Modified: branches/2.3/src/org/python/core/PyType.java > =================================================================== > --- branches/2.3/src/org/python/core/PyType.java 2006-07-20 12:39:44 UTC (rev 2852) > +++ branches/2.3/src/org/python/core/PyType.java 2006-07-20 21:34:24 UTC (rev 2853) > @@ -26,6 +26,7 @@ > dict.__setitem__("__base__",new PyGetSetDescr("__base__",PyType.class,"getBase",null)); > dict.__setitem__("__bases__",new PyGetSetDescr("__bases__",PyType.class,"getBases",null)); > dict.__setitem__("__mro__",new PyGetSetDescr("__mro__",PyType.class,"getMro",null)); > + dict.__setitem__("__flags__",new PyGetSetDescr("__flags__",PyType.class,"getFlags",null)); > class exposed_mro extends PyBuiltinFunctionNarrow { > > private PyType self; > @@ -392,6 +393,7 @@ > private PyObject[] bases; > private PyObject dict; > private PyObject[] mro; > + private long tp_flags; > private Class underlying_class; > private List slotnames; > > @@ -417,6 +419,10 @@ > public PyTuple getMro() { > return new PyTuple(mro); > } > + > + public PyLong getFlags() { > + return new PyLong(tp_flags); > + } > > public synchronized final PyObject type_getSubclasses() { > PyList result = new PyList(); > @@ -745,6 +751,17 @@ > newtype.base = base; > newtype.bases = bases_list; > > + /* initialize tp flags */ > + newtype.tp_flags=Py.TPFLAGS_DEFAULT | Py.TPFLAGS_HEAPTYPE | > + Py.TPFLAGS_BASETYPE; > + if ( (base.tp_flags & Py.TPFLAGS_HAVE_GC)>0 ) { > + newtype.tp_flags|=Py.TPFLAGS_HAVE_GC; > + } > + if ( (base.tp_flags & Py.TPFLAGS_CHECKTYPES)>0 ) { > + // || (base->tp_as_number == NULL)) { > + newtype.tp_flags |= Py.TPFLAGS_CHECKTYPES; > + } > + > newtype.needs_userdict = needs_userdict; > newtype.nuserslots = nuserslots; > newtype.hide_dict = hide_dict; > > Modified: branches/2.3/src/templates/type.expose > =================================================================== > --- branches/2.3/src/templates/type.expose 2006-07-20 12:39:44 UTC (rev 2852) > +++ branches/2.3/src/templates/type.expose 2006-07-20 21:34:24 UTC (rev 2853) > @@ -7,6 +7,7 @@ > expose_getset: __base__ getBase > expose_getset: __bases__ getBases > expose_getset: __mro__ getMro > +expose_getset: __flags__ getFlags > # classmethods > expose_cmeth: :o mro o? > # exposed methods > > > This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys -- and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Jython-checkins mailing list > Jython-checkins@... > https://lists.sourceforge.net/lists/listinfo/jython-checkins |
From: Samuele Pedroni <pedronis@st...> - 2006-07-20 21:46:15
|
Samuele Pedroni wrote: it's even buggy. HEAPTYPE should not be set by default, only if there's no underlying_class. |
From: Matt Small <msmall@ac...> - 2006-07-20 21:48:11
|
>>Revision: 2853 >>Author: m_small >>Date: 2006-07-20 14:34:24 -0700 (Thu, 20 Jul 2006) >>ViewCVS: http://svn.sourceforge.net/jython/?rev=2853&view=rev >> >>Log Message: >>----------- >>basic support for __flags__ in PyType > > > this doesn't look much basic too me. Any particular reason to do more > than support the flag settings used by pickle. This __flags__ are really > an implementationd detail of CPython, is kind of unfortunate that > pickle.py depends on them, but I don't see the point of doing more than > satisfying the minimal requirements, this is what I would do and PyPy > does. Notice that the less code the better. Actually, that's a good point. If we can get by with just this (and I think this is all I need for pickle), so much the better. -matt |
From: Matt Small <msmall@ac...> - 2006-07-20 22:48:16
|
>> I'm going to look at __getnewargs__ next. >> >> Regarding the underlying_class, where are you seeing that? I was >> looking at typeobject.c:1807, where HEAPTYPE always seems to be set, >> but it's definitely likely that I've missed something.. :) >> > > because in Jython the code is shared between creating user types and > setting up builtin types. The latter go through a different route in > CPython using a constant struct for the type, that's how they don't get > their HEAPTYPE flag. Ahh, thanks. I'm taking a look at this now. Good eyes! |
From: Matt Small <msmall@ac...> - 2006-07-21 00:58:45
Attachments:
flagtest.py
|
>>because in Jython the code is shared between creating user types and >>setting up builtin types. The latter go through a different route in >>CPython using a constant struct for the type, that's how they don't get >>their HEAPTYPE flag. > > > Ahh, thanks. I'm taking a look at this now. Good eyes! I think I'm misunderstanding something. In Jython, none of the builtin types (file, list, tuple, etc) seem to go through PyType.newType(), where I put the code to add HEAPTYPE. Are you thinking of PyPy, where they do share a codepath? If you can think of any other edge cases that I may not have taken into account, please let me know. I've attached a little script I've been using to test. -matt |
From: Samuele Pedroni <pedronis@st...> - 2006-07-20 22:01:00
|
Matt Small wrote: >>>Revision: 2853 >>>Author: m_small >>>Date: 2006-07-20 14:34:24 -0700 (Thu, 20 Jul 2006) >>>ViewCVS: http://svn.sourceforge.net/jython/?rev=2853&view=rev >>> >>>Log Message: >>>----------- >>>basic support for __flags__ in PyType >> >> >>this doesn't look much basic too me. Any particular reason to do more >>than support the flag settings used by pickle. This __flags__ are really >>an implementationd detail of CPython, is kind of unfortunate that >>pickle.py depends on them, but I don't see the point of doing more than >>satisfying the minimal requirements, this is what I would do and PyPy >>does. Notice that the less code the better. > > > Actually, that's a good point. If we can get by with just this (and I > think this is all I need for pickle), so much the better. > related to pickle some immutable builtin type expose a __getnewargs__ |
From: Matt Small <msmall@ac...> - 2006-07-20 22:22:35
|
I'm going to look at __getnewargs__ next. Regarding the underlying_class, where are you seeing that? I was looking at typeobject.c:1807, where HEAPTYPE always seems to be set, but it's definitely likely that I've missed something.. :) Samuele Pedroni wrote: > Matt Small wrote: > >>>> Revision: 2853 >>>> Author: m_small >>>> Date: 2006-07-20 14:34:24 -0700 (Thu, 20 Jul 2006) >>>> ViewCVS: http://svn.sourceforge.net/jython/?rev=2853&view=rev >>>> >>>> Log Message: >>>> ----------- >>>> basic support for __flags__ in PyType >>> >>> >>> >>> this doesn't look much basic too me. Any particular reason to do more >>> than support the flag settings used by pickle. This __flags__ are really >>> an implementationd detail of CPython, is kind of unfortunate that >>> pickle.py depends on them, but I don't see the point of doing more than >>> satisfying the minimal requirements, this is what I would do and PyPy >>> does. Notice that the less code the better. >> >> >> >> Actually, that's a good point. If we can get by with just this (and I >> think this is all I need for pickle), so much the better. >> > > related to pickle some immutable builtin type expose a __getnewargs__ |
From: Samuele Pedroni <pedronis@st...> - 2006-07-20 22:25:50
|
Matt Small wrote: > I'm going to look at __getnewargs__ next. > > Regarding the underlying_class, where are you seeing that? I was > looking at typeobject.c:1807, where HEAPTYPE always seems to be set, but > it's definitely likely that I've missed something.. :) > because in Jython the code is shared between creating user types and setting up builtin types. The latter go through a different route in CPython using a constant struct for the type, that's how they don't get their HEAPTYPE flag. > Samuele Pedroni wrote: > >> Matt Small wrote: >> >>>>> Revision: 2853 >>>>> Author: m_small >>>>> Date: 2006-07-20 14:34:24 -0700 (Thu, 20 Jul 2006) >>>>> ViewCVS: http://svn.sourceforge.net/jython/?rev=2853&view=rev >>>>> >>>>> Log Message: >>>>> ----------- >>>>> basic support for __flags__ in PyType >>>> >>>> >>>> >>>> >>>> this doesn't look much basic too me. Any particular reason to do more >>>> than support the flag settings used by pickle. This __flags__ are >>>> really >>>> an implementationd detail of CPython, is kind of unfortunate that >>>> pickle.py depends on them, but I don't see the point of doing more than >>>> satisfying the minimal requirements, this is what I would do and >>>> PyPy does. Notice that the less code the better. >>> >>> >>> >>> >>> Actually, that's a good point. If we can get by with just this (and >>> I think this is all I need for pickle), so much the better. >>> >> >> related to pickle some immutable builtin type expose a __getnewargs__ |