These are chat archives for dropbox/pyston

13th
May 2016
Marius Wachtler
@undingen
May 13 2016 08:58
@sun pointed out to me that there is a difference in output between the output of hex(np.int64(0)) between cpython an pyston
I tracked down to how we do the lookup in hex() cpython directly calls tp_as_number->nb_hex and we do the "full lookup" (calling cls.__hex__(v)).
I can reproduce it in cpython:
>>> i = np.int64(0)
>>> hex(i)
'0x0L'
>>> i.__hex__()
'0x0'
how should we handle that? should we just change our builtins func implementations to directly call into the slots? (if we implement more of this slots for our types this should even be a perf improvement I guess)
Marius Wachtler
@undingen
May 13 2016 09:03
but generally it's quite ugly that the slot and the attribute for this numpy type don't agree on which function to call :-(
Sun
@Daetalus
May 13 2016 10:33
You mean call nb_hex slot directly may have a perf improvement?
@undingen
Marius Wachtler
@undingen
May 13 2016 10:34
if it's a c capi type it should be much faster. for python types it's probably a little bit slower
and for our c++ api types (I mean the cls->setAttr(__hex__,...) thing) it's probably also a little bit slower but we can easily set this slots when we define the types to get the same speed as using the c api.
it will not allow us to do rewrites but we don't do this currently for this builtins...
Sun
@Daetalus
May 13 2016 10:37
You mean when we do cls->setAttr(__hex__, ...), we can also set cls->nb_hex = xxx?
Marius Wachtler
@undingen
May 13 2016 10:38
yes we can set them both for an additional perf improvement in case someone calls the slot directly
we already do this for some stuff
Sun
@Daetalus
May 13 2016 10:39
I see. Let's try to @njsmith .
Marius Wachtler
@undingen
May 13 2016 10:39
e.g. long_cls->giveAttr("__hash__", and long_cls->tp_hash = long_hash; or __pow__
Sun
@Daetalus
May 13 2016 10:40
I see.

skipped a lot of stuff until we call into runtimeCallInternal

How to skip those stuff? By type next in gdb?

Marius Wachtler
@undingen
May 13 2016 10:43
I just put a breakpoint into runtimeCallInternal and continued. Because I know that callattrInternal will eventually call into that.
Sun
@Daetalus
May 13 2016 10:43
I see, thank you!
Marius Wachtler
@undingen
May 13 2016 10:43
np
with this new gitter design I find it annoying to switch between direct communication channel and the public one. so one more reason to use this one more often :-D
Sun
@Daetalus
May 13 2016 10:46
Agree, I will discuss everything in here, but FYI, click the up-left, "All conversations" could solve it.
Marius Wachtler
@undingen
May 13 2016 10:55
oh thanks, that makes it much easier to switch channels.