Commit 8958817f authored by Robert Bradshaw's avatar Robert Bradshaw

Optimize bool by starting as bint rather than object.

parent 4896ddf8
......@@ -588,25 +588,6 @@ class NoneNode(PyConstNode):
def compile_time_value(self, denv):
return None
class BoolNode(PyConstNode):
# The constant value True or False
def compile_time_value(self, denv):
return self.value
def calculate_result_code(self):
if self.value:
return "Py_True"
else:
return "Py_False"
def coerce_to(self, dst_type, env):
value = self.value
if dst_type.is_numeric:
return IntNode(self.pos, value=int(self.value)).coerce_to(dst_type, env)
else:
return PyConstNode.coerce_to(self, dst_type, env)
class EllipsisNode(PyConstNode):
# '...' in a subscript list.
......@@ -639,6 +620,16 @@ class ConstNode(AtomicExprNode):
pass
class BoolNode(ConstNode):
type = PyrexTypes.c_bint_type
# The constant value True or False
def compile_time_value(self, denv):
return self.value
def calculate_result_code(self):
return int(self.value)
class NullNode(ConstNode):
type = PyrexTypes.c_null_ptr_type
value = "NULL"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment