These are chat archives for dropbox/pyston

Mar 2016
Mar 10 2016 16:43
Hi, @kmod , for str * A, A is a custom object with __index__ object (actually, it is an numpy array, if it contain more than one element, it will report a TypeError). In str * A, the current implementation is check the rhs has __index__ attr or not. If has, get the index integer from it, then if error occured, throw that exception. However, numpy object, chararray, has __index__ attr, and will raise error. So no chance to let Pyston to choose chararray's multiply.
This is my implementation of strMul, Daetalus/pyston@9e76673
import numpy as np
A = np.array([['abc', '123'],
              ['789', 'xyz']]).view(np.chararray)
os = 'qrs'
print(os * A)
Kevin Modzelewski
Mar 10 2016 17:02
Maybe it's time that we have to implement it the same way that cpython does :/
Marius Wachtler
Mar 10 2016 17:04
Kevin Modzelewski
Mar 10 2016 17:04
I think "return NotImplemented on IndexError" also has some differences from cpythons behavior. Again it seems small but it's feeling like any difference here is going to end up biting us
And by "the same way that cpython does" I mean changing binop() to try nb_multiply first and then try sq_concat last
Nathaniel J. Smith
Mar 10 2016 19:25
Yeah, the multiply/concat thing in cpython sucks, but it turns out that there's code in the wild that depends on it (including numpy). The PyPy folks had to implement it too.
There's some python-dev or conversation I could dig up if necessary, where Nick Coghlan gets all excited about fixing it in cpython and then realizes how doomed he is.
Kevin Modzelewski
Mar 10 2016 23:25
Heh we've come full circle!
I think Daetalus's comment is related to his last pr, dropbox/pyston#1054
in which I referenced the thread that you were on on python-dev
Nathaniel J. Smith
Mar 10 2016 23:55
ah yep that's the thread I was thinking about :-)
or one of them at least