示例#1
0
    def _key_builder(self):
        from loopy.tools import LoopyEqKeyBuilder
        key_builder = LoopyEqKeyBuilder()
        key_builder.update_for_class(self.__class__)

        for field_name in self.fields:
            field_value = getattr(self, field_name)
            if field_name in self.pymbolic_fields:
                key_builder.update_for_pymbolic_field(field_name, field_value)
            elif field_name in self.pymbolic_set_fields:
                # First sort the fields, as a canonical form
                items = tuple(sorted(field_value, key=str))
                key_builder.update_for_pymbolic_field(field_name, items)
            else:
                key_builder.update_for_field(field_name, field_value)

        return key_builder
示例#2
0
    def _key_builder(self):
        from loopy.tools import LoopyEqKeyBuilder
        key_builder = LoopyEqKeyBuilder()
        key_builder.update_for_class(self.__class__)

        for field_name in self.fields:
            field_value = getattr(self, field_name)
            if field_name in self.pymbolic_fields:
                key_builder.update_for_pymbolic_field(field_name, field_value)
            elif field_name in self.pymbolic_set_fields:
                # First sort the fields, as a canonical form
                items = tuple(sorted(field_value, key=str))
                key_builder.update_for_pymbolic_field(field_name, items)
            else:
                key_builder.update_for_field(field_name, field_value)

        return key_builder
示例#3
0
    def _key_builder(self):
        from loopy.tools import LoopyEqKeyBuilder
        key_builder = LoopyEqKeyBuilder()
        key_builder.update_for_class(self.__class__)

        for field_name in self.fields:
            field_value = getattr(self, field_name)
            if field_name in self.pymbolic_fields:
                key_builder.update_for_pymbolic_field(field_name, field_value)
            elif field_name in self.pymbolic_set_fields:
                # First sort the fields, as a canonical form
                items = tuple(sorted(field_value, key=str))
                key_builder.update_for_pymbolic_field(field_name, items)

            # from CExpression
            elif field_name == "iname_exprs":
                from loopy.symbolic import EqualityPreservingStringifyMapper
                key_builder.field_dict[field_name] = [
                        (iname, EqualityPreservingStringifyMapper()(expr)
                            .encode("utf-8"))
                        for iname, expr in self.iname_exprs
                        ]

            else:
                key_builder.update_for_field(field_name, field_value)

        return key_builder