Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: hylang/hy
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 82a20f7bfdec97e5a6e6678745d327bfc88bfeed
Choose a base ref
..
head repository: hylang/hy
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 435ec2f35e8666a9f5214e554672d6bd5f8f9e46
Choose a head ref
Showing with 7 additions and 9 deletions.
  1. +7 −9 hy/contrib/hy_repr.hy
16 changes: 7 additions & 9 deletions hy/contrib/hy_repr.hy
Original file line number Diff line number Diff line change
@@ -7,15 +7,6 @@
[hy._compat [PY3 str-type bytes-type long-type]]
[hy.models [HyObject HyExpression HySymbol HyKeyword HyInteger HyFloat HyComplex HyList HyDict HySet HyString HyBytes]])

(defn base-repr [x]
(unless (instance? HyObject x)
(return (repr x)))
; Call (.repr x) using the first class of x that doesn't inherit from
; HyObject.
(.__repr__
(next (genexpr t [t (. (type x) __mro__)] (not (issubclass t HyObject))))
x))

(defn hy-repr [obj]
(setv seen (set))
; We keep track of objects we've already seen, and avoid
@@ -100,3 +91,10 @@
; else
(base-repr x))))
(f obj False))

(defn base-repr [x]
; Call (.repr x) using the first class of x that doesn't inherit from
; HyObject.
(.__repr__
(next (genexpr t [t (. (type x) __mro__)] (not (issubclass t HyObject))))
x))