{"action":"created","issue":{"url":"https://api.github.com/repos/dropbox/pyston/issues/466","labels_url":"https://api.github.com/repos/dropbox/pyston/issues/466/labels{/name}","comments_url":"https://api.github.com/repos/dropbox/pyston/issues/466/comments","events_url":"https://api.github.com/repos/dropbox/pyston/issues/466/events","html_url":"https://github.com/dropbox/pyston/pull/466","id":71232144,"number":466,"title":"slots (WIP)","user":{"login":"tjhance","id":592054,"avatar_url":"https://avatars.githubusercontent.com/u/592054?v=3","gravatar_id":"","url":"https://api.github.com/users/tjhance","html_url":"https://github.com/tjhance","followers_url":"https://api.github.com/users/tjhance/followers","following_url":"https://api.github.com/users/tjhance/following{/other_user}","gists_url":"https://api.github.com/users/tjhance/gists{/gist_id}","starred_url":"https://api.github.com/users/tjhance/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tjhance/subscriptions","organizations_url":"https://api.github.com/users/tjhance/orgs","repos_url":"https://api.github.com/users/tjhance/repos","events_url":"https://api.github.com/users/tjhance/events{/privacy}","received_events_url":"https://api.github.com/users/tjhance/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2015-04-27T09:32:00Z","updated_at":"2015-05-05T05:42:31Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/dropbox/pyston/pulls/466","html_url":"https://github.com/dropbox/pyston/pull/466","diff_url":"https://github.com/dropbox/pyston/pull/466.diff","patch_url":"https://github.com/dropbox/pyston/pull/466.patch"},"body":"There are still a couple of tests failing (including the one with the recursive GC call that I talked about on Gitter... I'm still not sure if that's partially the fault of this diff or not), but I'll go ahead and put it up here. Also, this ended up being one of those diffs where I fix one thing and that leads to fixing another thing...\r\n\r\nAnyway, here is what is happening in this diff:\r\n- In `typeNew`, I add support for `__slots__`. This adds a member descriptor for each name in the slots array. Also, if `__dict__` is in the slots, then it adds a dict (well, really an attrs, since it's pyston).\r\n- Hopefully this should reduce allocations since most objects with __slots__ won't have to allocate attrs.\r\n- To garbage collect the slots, we need to keep track of the slot locations in the type object. CPython lists `PyMemberDef`s at the end of a type object. We don't need the full `PyMemberDef` struct (as far as I know--maybe the c api requires it though), but for now, I just put the slot offsets in a variable array in the type object.\r\n- In the process of writing the above, logic, I stumbled across a tangential problem with the way we add a dict (or in our case, attrs) to a class when subclassing a class that is variable-size. This is tricky, since you have to leave the base layout alone, but that means you don't have a fixed offset to put the dict afterwards. CPython solves this by allowing `tp_dictoffset` to be negative, so you can offset it from the *end* of the object. From the [https://docs.python.org/2/c-api/typeobj.html#c.PyTypeObject.tp_dictoffset](python docs):\r\n\r\n> If the value is less than zero, it specifies the offset from the end of the instance structure. A negative offset is more expensive to use, and should only be used when the instance structure contains a variable-length part. This is used for example to add an instance variable dictionary to subtypes of str or tuple. Note that the tp_basicsize field should account for the dictionary added to the end in that case, even though the dictionary is not included in the basic object layout.\r\n\r\nIn the process of supporting this, I had to make sure that string and tuple subclassed `VarBox` and set the `ob_size` field. It's a bit messy and I think more can be done here to clean things up, but I didn't want to dig too far on this since, again, it's kind of tangential."},"comment":{"url":"https://api.github.com/repos/dropbox/pyston/issues/comments/98961148","html_url":"https://github.com/dropbox/pyston/pull/466#issuecomment-98961148","issue_url":"https://api.github.com/repos/dropbox/pyston/issues/466","id":98961148,"user":{"login":"kmod","id":271916,"avatar_url":"https://avatars.githubusercontent.com/u/271916?v=3","gravatar_id":"","url":"https://api.github.com/users/kmod","html_url":"https://github.com/kmod","followers_url":"https://api.github.com/users/kmod/followers","following_url":"https://api.github.com/users/kmod/following{/other_user}","gists_url":"https://api.github.com/users/kmod/gists{/gist_id}","starred_url":"https://api.github.com/users/kmod/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kmod/subscriptions","organizations_url":"https://api.github.com/users/kmod/orgs","repos_url":"https://api.github.com/users/kmod/repos","events_url":"https://api.github.com/users/kmod/events{/privacy}","received_events_url":"https://api.github.com/users/kmod/received_events","type":"User","site_admin":false},"created_at":"2015-05-05T05:42:31Z","updated_at":"2015-05-05T05:42:31Z","body":"ok let's save the \"convert BoxedString to have a array at a constant offset\" part for another PR (I just noticed that your \"clean up BoxedTuple\" change does this for tuples).  I was thinking that `BoxedString::s` could be a function that constructed the StringRef on demand."}}