Luke Kenneth Casson Leighton <lkcl@samba-tng.org> writes: > one of these - pow(int(5), UserLong(3), 26) - is failing: What's the point of UserLong now we have 2.2? > Script started on Wed May 1 19:06:30 2002 > highfield:/usr/local/lib/python2.2# python UserLong.py > int 3 > long 3 > 5**int(y) 125 > 5**y rpow: (5,) > 3 > x^y%26 (3L, 26) > 21L > 5^y%26 > Traceback (most recent call last): > File "UserLong.py", line 153, in ? > print "5^y%26", pow(5, y, 26) > TypeError: unsupported operand type(s) for pow(): 'int', 'instance', 'int' > highfield:/usr/local/lib/python2.2# > Script done on Wed May 1 19:06:37 2002 > > now, if i read this correctly, what is happening is that in > the [optimised] code, Objects/intobject.c, support for types > other than int, float and long - via the macro CONVERT_TO_LONG - > are simply not supported. > > this i believe can be demonstrated to be so because if you > do pow(5, [], 26) you get the same error except replace > 'instance' above with 'list'. > > now, could someone with a little more knowledge than i kindly > evaluate, if they have the time, whether: > > - _is_ this happening because i have missed out a function in > UserLong.py that i do not know the name of? > > or: > > - _is_ this due to a bug in intobject.c's int_pow() > > or: > > - _is_ this due to a bug in the implementation of the pow() > "spam" function? > > - other? Are you aware of this text in section 3.3.6 of the lang ref: Note that ternary pow() will not try calling __rpow__() (the coercion rules would become too complicated). so I'd say this is, if anything, a "documented limitation", though that might something of a stretch... Cheers, M. -- The meaning of "brunch" is as yet undefined. -- Simon Booth, ucam.chat
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4