lupa
lupa copied to clipboard
Surprising table equality behavior
import lupa r = lupa.LuaRuntime() r.globals().test == r.globals().test False
I can supply a patch that adds richcmp and hash to _LuaTable.
Sounds like a good idea.
I never got around to adding the patch :-P. Here it is! https://gist.github.com/dubois/9478877
Thanks. A couple of comments:
- looks very good functionality wise
- lacks tests
- I prefer pull requests :)
- "richcmp()" is bidirectional, so you can't be sure the first argument is "self", it might be the second (which is, I guess, why you thought you'd have to type the first argument explicitly)
- "uintptr_t" appears to be C99. Not sure I want to require that. There's also the "stdint.h not in MSVC" issue. Tricky ground.
- the comparison operators should use the CPython constants (from cpython.object cimport Py_EQ, ...), not plain integers. There's also no need to explicitly return True/False, just return the comparison result.
- there's a special type "Py_hash_t" that Cython defines as return value of "hash()" (and that it backports for Py<3.2)
I'm pretty sure this occurs with all _LuaObject
, since I've experienced this with _LuaFunction
too
Don't know why this was closed. Doesn't look like it's resolved. PR welcome, as described above.