Support direct assignment of weakref.ref
Remove `defer` function
Use `__slots__` for class `ref`
Add doctest for class `ref`