tessl install tessl/pypi-frozendict@2.4.0A simple immutable dictionary implementation with hashing support and performance optimizations
Agent Success
Agent success rate when using this tile
85%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.31x
Baseline
Agent success rate without this tile
65%
Build a utility that converts data structures containing custom objects into deeply frozen immutable versions. The utility should register custom conversion rules and apply them when freezing.
Implement functionality that:
Point and Rectangle classes@generates
class Point:
"""Mutable point with x, y coordinates."""
def __init__(self, x, y):
self.x = x
self.y = y
def __eq__(self, other):
return isinstance(other, Point) and self.x == other.x and self.y == other.y
class Rectangle:
"""Mutable rectangle with width and height."""
def __init__(self, width, height):
self.width = width
self.height = height
def __eq__(self, other):
return isinstance(other, Rectangle) and self.width == other.width and self.height == other.height
def setup_custom_converters():
"""
Register custom type converters for Point and Rectangle classes.
Point should convert to tuple: Point(x, y) -> (x, y)
Rectangle should convert to dict: Rectangle(w, h) -> {"w": w, "h": h}
Also register inverse converters for round-trip conversion.
"""
pass
def freeze_with_custom_types(obj):
"""
Deep freeze an object using the registered custom converters.
Args:
obj: The object to freeze (typically a dict or list containing custom types)
Returns:
A deeply frozen immutable version with custom types converted
"""
passProvides immutable dictionary implementation with deep freeze functionality and custom converter registration.