Skip to content

Subclassing the bool from long instead int object.#1424

Open
Daetalus wants to merge 6 commits into
pyston:py3from
Daetalus:bool_update_1
Open

Subclassing the bool from long instead int object.#1424
Daetalus wants to merge 6 commits into
pyston:py3from
Daetalus:bool_update_1

Conversation

@Daetalus

@Daetalus Daetalus commented Jul 1, 2017

Copy link
Copy Markdown
Contributor

In Python 2, the bool object is essentially an int object. In Python 3, it is long object. This PR subclass the bool object from long instead of the int. Preparing for removing the int object completely.

@Daetalus

Daetalus commented Jul 3, 2017

Copy link
Copy Markdown
Contributor Author

@kmod

Comment thread src/runtime/types.cpp Outdated
bool_cls->tp_mro = BoxedTuple::create({ bool_cls, int_cls, object_cls });
complex_cls->tp_mro = BoxedTuple::create({ complex_cls, object_cls });
long_cls->tp_mro = BoxedTuple::create({ long_cls, object_cls });
bool_cls->tp_mro = BoxedTuple::create({ bool_cls, int_cls, object_cls });

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You'll need to update this to be long_cls instead of int_cls.

@kmod

kmod commented Jul 8, 2017

Copy link
Copy Markdown
Collaborator

Looks awesome! Let's get a small test file set up, something like this:

long_ = type(1L)
assert isinstance(True, long_)
assert issubclass(bool, long_)
print(bool.__bases__)

Daetalus added 6 commits July 12, 2017 03:57
In Python 2, the bool object just a int object. In Python 3, the bool object become long object. So change the bool object to the subclass of long object, prepare for other Python 3 updates.
If any tests ready to python 3, we need to add 'py3ready' flag in the beginning of the file
cmake 2 can not build target Ninja.
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