[pypy-dev] array performace?

Bengt Richter bokr at oz.net
Sat Jul 3 02:38:16 CEST 2010

On 07/02/2010 04:14 PM Amaury Forgeot d'Arc wrote:
> Hi,
> 2010/7/3 Bengt Richter <bokr at oz.net>:
>> A thought/question:
>> Could/does JIT make use of information in an assert statement? E.g., could we write
>>     assert set(type(x) for x in img) == set([float]) and len(img)==640*480
>> in front of a loop operating on img and have JIT use the info as assumed true
>> even when "if __debug__:" suites are optimized away?
>> Could such assertions allow e.g. a list to be implemented as a homogeneous vector
>> of unboxed representations?
>> What kind of guidelines for writing assertions would have to exist to make them
>> useful to JIT most easily?
> If efficient python code needs this, I'd better write the loop in C
> and explicitly choose the types.
> The C code could be inlined in the python script, and compiled on demand.
> At least you'll know what you get. 
Well, even C accepts hints like 'register' (and may ignore you, so you are not truly sure what you get ;-)

The point of using assert would be to let the user remain within the python language, while still passing
useful hints to the compiler.

If I wanted to mix languages (not uninteresting!), I'd go with
racket (the star formerly known as PLT-scheme)

They have extended programmability right down to the reader/tokenizer,
so it might well be possible for them to accept literal C as a translated sub/macro-language,
given the appropriate syntax definitions written in racket. For more, see
and more specifically

Bengt Richter

More information about the Pypy-dev mailing list