These are chat archives for dropbox/pyston

27th
Aug 2015
Satyajit Sarangi
@ssarangi
Aug 27 2015 22:41
hi guys.. i had a question about how pyston generates llvm ir.. does it do type inference before generating llvm ir ?
Kevin Modzelewski
@kmod
Aug 27 2015 22:51
a little bit
Satyajit Sarangi
@ssarangi
Aug 27 2015 22:52
so what happens when it fails to do type inference
do you interpret it instead of generating ir ?
Kevin Modzelewski
@kmod
Aug 27 2015 22:52
it generates calls into the runtime functions
that handle the full dynamic dispatch
and then the use inline caching to make subsequent runs fast
Satyajit Sarangi
@ssarangi
Aug 27 2015 22:53
interesting...
so i am looking at this snippet
def foo(v):
if v == 1:
v = []
elif v == 2:
v = {}
else:
v = "hello"
return v
and wondering what ir could be generated for it
Kevin Modzelewski
@kmod
Aug 27 2015 22:56
well, we'll just store v as a generic object
and return it as one
Satyajit Sarangi
@ssarangi
Aug 27 2015 22:58
so as a generic object, how would access to it on the caller side work. Lets say, the caller does something like... res = foo(2) and then res[2]
assuming the list / dict is populated
instead of being empty
so then since v is a generic object, do you have a gep to access that ?
Kevin Modzelewski
@kmod
Aug 27 2015 22:58
well, first off we don't do any cross-function type analysis, at least currently
but we do do some speculation
so if you always pass 2 as the argument, then we will learn that v is a dict
but anyway, assuming that that doesn't happen
we will emit a call to getitem(res, boxInt(2))
Satyajit Sarangi
@ssarangi
Aug 27 2015 22:59
aah i see..