
I was playing with translator frontend, writing random snippets. And I discovered FlowObjSpace currently lacks newslice interface. Does RPython have slice? I checked StdObjSpace implementation. slicefind.sh is located at SVN repo user/sanxiyn/script. Slice is currently used only in stringojbect, namely split, strip, count, startswith, endswith, and repr. (Two matches in listobject doesn't need to be RPython.) It wouldn't be hard to rewrite them without slice. I remember a discussion on IRC whose log I posted for a while ago: in RPython, op should be able to be implemented efficiently, or be disallowed. And flowgraph transformation was suggested. Perhaps slice to sans-slice transformation should be written, and translators may or may not use the transformation? Seo Sanghyeon

Hello Seo, On Fri, Oct 24, 2003 at 12:05:54PM +0900, Seo Sanghyeon wrote:
Does RPython have slice?
I am not too familiar with std/stringobject.py, I can't say how this code should be translated or if it shouldn't have used slices in the first place. In general I think that slicing from a list can be regarded as the operation of malloc()ating a new, smaller list and memcpy()ing data around, which is fine as long as you are aware of this. Depending on the code generators, it may be useful as you suggest to have general graph transformations that change unsupported constructs into reasonably efficient lower-level supported ones. I can imagine that (using type inference) we could change newslice/getitem pairs into, say, malloc followed by an explicit loop of getitem/setitem. BTW (in case you're not already aware of this) the Lisp generator will have to be fixed at some point, because it cannot simply translate "add" into "+". This only works if type inference says the arguments are integers. A bientot, Armin.
participants (2)
-
Armin Rigo
-
Seo Sanghyeon