-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object representation in Variable Explorer #310
Comments
Hey @jpcanal, thanks for reporting. This needs to be addressed in spyder-kernels, not here, so I'm moving your issue there. |
The problem we found a while ago is that slow or badly implemented So we preferred to only trust in the For that we could use one of the solutions described in this SO post: https://stackoverflow.com/questions/366682/how-to-limit-execution-time-of-a-function-call In particular, I really like this one: |
The only problem with that is that a way to run a function until a timeout is reached that works in all operating systems involves using threads. And I don't know if that could work with the rest of our architecture. @impact27, what do you think about this? |
I guess a mid-term solution would be to add an option on the right side menu, perhaps? In the same way that you added "Show arrays min/max", perhaps an option for "Retrieve objects representation" could be added? Disabled by default, the option may be enabled by the user. If the console starts to lag, the user can disable it and get back the generic description. I don't know in which case you saw the knock down, but I wouldn't expect a problem for most "simple" objects... However, even in the default description case, I see it a bit too generic... I mean, PyCharm default description is something like |
Or we could have a thread to compute the reps? |
I disagree with that for the following reasons:
Numpy repr's were terribly inefficient some years ago (I don't know if that has improved). But simply having this class Foo
def __repr___(self):
import time
time.sleep(100)
foo = Foo() will block the console for 100 seconds. So we can't trust generic repr's unless we're able to prevent that.
We decided to do that so that our descriptions make sense for people that don't know that However, I agree that it'd be nice to add an option to show that info for power users (disabled by default, of course). |
@impact27, the problem with that is that the Variable Explorer would be out of sync with the console namespace, even more so for slow to compute repr's. So I prefer to leave this call to be blocking and adding a timeout to the method or function that tries to read the repr of an object. |
I agree with you on the best solution: time-out thread. I guess it is also the most complex...
I don't know if would call them power users... I would guess most users positively appreciate Variable Explorer visual approach over bare interpreter, and that is one of the reasons for their preference. You can find examples in the same standard library, e.g.:
where you get Besides, I would consider the same improvement would apply to the Object Explorer too, for the value of the object. Here I understand the limitation is not lagging, as |
Problem Description
In the variable explorer, non-standard objects value is redundant with type.
__str__
or__repr__
result would be expected to be seen, which usually carries useful information about the object.Standard Python objects are cleared for representation visualization, but not any object (comment about this on spyder-ide/spyder#1867).
A performance issue is mentioned in the link, but I think PyCharm does show this representation for custom objects.
What steps reproduce the problem?
Vector
and Value isVector object of __main__ module
.What is the expected output? What do you see instead?
Value column is expected to be populated with
Vector (x=1.000000, y=2.000000, z=3.000000)
or similar information about the object, asprint(obj)
would show.Versions
The text was updated successfully, but these errors were encountered: