|
From: Samuele P. <pe...@in...> - 2001-08-07 22:33:20
|
... > > > For demonstration purposes I'm embedding the feature > in directly into the PyInstance. I define a new > private method called setSkeleton in PyInstance.java. Make sense for demo, but for the long run is a no-go. > > > I add a bit of code in __setattr__ and __findattr__ > which will search the skeleton instance first before > self. When setting the attribute I check to see if it > is a "basis type" (i.e. float int string). If it is > not I must check that object to see if it has a > skeleton. If so, set the ghost attribute with the > ob's skeleton. > > > I include an extra optional argument to init args > called __skeleton__. If it's None I do nothing, if it > is defined, I set the PyInstance's skeleton class > before we assign attributes to the instance. This way > the skeleton will automatically be initialized since > __setattr__ and __findattr__ have been slightly > modified. > > > What is important about the nature of ghosting is that > information is stored in both the java native skeleton > and the real PyObject. Why this two-places approach? once you have a skeleton you can store things there, unless an attribute is not a pre-existent java field. > > This seems funny, and alot of work, but really isn't. > Once you see the speed boost obtained from doing bulk > processing you may deem this feature worthwhile. OK, but you stil pay reflection for calling java methods, so you get a real speedup maybe only if your java methods are coarse-grain. > > > It does retain a great deal of python flexibility. > Provided a small set of attributes are not deleted. > That should throw an exception. > > > thanks for your comments. have been very helpful. > -john You're welcome. For the momement I see this as an interesting experiment, but to have such a functionality be distributed with jython I think we need the 2.2 framework, in order to make this a flavor of java subclassing under the control of a special-purpose meta-class. At least I hope that these words will make sense at that point. regards, Samuele Pedroni. |