Skip to content

Add some function to old style class #787

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 1, 2015
Merged

Conversation

Daetalus
Copy link
Contributor

Note:

  • The __complex__ could call complexNew in complex.cpp correctly. But complexNew need some improvements to support str and custom type.
  • The behaviors of __unicode__, __get__, __set__, __delete__ are exact same as in CPython. IMHO, there is no need to write additional code in classobj.cpp.
  • __missing__ only work in subclass of dict. So no need to write it in classobj.cpp.
  • __coerce__ in old style class could call the new added coerce builtin function correctly. But the coerce need further improvements.

Update

  • According import types; print sorted(types.InstanceType.__dict__.keys()) in CPython. Pyston has extra __base__.
  • __doc__, __new__ seems as instance's class attributes in Pyston. If these three attribute were fine, then the old style class support was completed.
  • __getslice__ and some other functions didn't change. Because if we copy instance_slice from CPython, then apply some change, it will very similar as the current one. But I will try to copy CPython code in next PR as much as possible.

@kmod
Copy link
Collaborator

kmod commented Jul 30, 2015

Oh hmm you're right, there's no need to add a bunch of the ones that I had mentioned. I should have done this instead: import types; print sorted(types.InstanceType.__dict__.keys())

Looks like maybe we should remove these reversed, complex, enter, and exit, and add __index__. Sorry! Otherwise the change looks good.

}

return runtimeCall(getslice_func, ArgPassSpec(2), i, j, NULL, NULL, NULL);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor (not worth changing), but we could have directly copied CPython's instance_slice. It looks like the conversion got rid of some overhead, but I've been liking the approach of starting out with a 100% copy and then optimize as needed.

kmod added a commit that referenced this pull request Aug 1, 2015
Add some function to old style class
@kmod kmod merged commit 3f88340 into pyston:master Aug 1, 2015
@kmod
Copy link
Collaborator

kmod commented Aug 1, 2015

Awesome! Looks like we can now close #254 👍

fyi github doesn't send any notifications when you add new commits to a pull request, so if you leave a comment on it I will get back to you faster :)

@Daetalus Daetalus deleted the old_style_class branch August 1, 2015 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants