1. masklinn
  2. py.js
  3. Issues
Issue #8 resolved

Fix __hash__ and implement it for str

repo owner created an issue

Currently, {{{hash}}} returns an integer as defined by the Python data model.

But because JS already has objects and they only take string keys, it would probably be a good idea to diverge from the data model and use strings as {{{hash}}} results as well (after all, the data model defines the default {{{o.hash()}}} as returning {{{id(o)}}} yet pypy does not implement that). That way it's trivial to use a JS object as a backing map, at least until JS gets "real" arbitrary-typed hashmaps.

TODO: Return some sort of tagged (prefix with a weird/unprintable character) hash string on a counter by default Implement {{{hash}}} on {{{str}}} (just return the actual value with a prefix) * ?handle a sub-class defining a {{{hash}}} of {{{null}}} to make the type unhashable, have {{{setitem}}} raise {{{TypeError: unhashable type: '???'}}} when {{{o.hash === null}}}

Comments (1)

  1. Log in to comment