That is definitely not language-behavior material - and should be a worry of the authors of whatever projects have objects that demand so much processing to generate a "repr".
It certainly is not a common problema met with - I often have to deal with cumbersome repr's (even in my own projects), but due to their size. If an object performs recursive external-resource queries just for ordinarily printing a repr, to a point it is getting in the way of interactive use it obviously should not, and should create a separate "full_repr(...)" method for that. note that you can _already_ accept an optional parameter in the `__repr__` method to behave like you proposed - or your `__repr__` could check a setting somewhere to find out the behavior it should have. On Fri, 24 Jul 2020 at 12:14, Gábor Bernát <jokerjoke...@gmail.com> wrote: > Hello, I'd like to bring to your attention > https://bugs.python.org/issue41383. The core idea here is per Elizaveta > Shashkova: > > I would like to have a lazy repr evaluation for the objects! Sometimes > users have many really large objects, and when debugger is trying to show > them in Variables View (=show their string representation) it can takes a > lot of time. We do some tricks, but they not always work. It would be > really-really cool to have parameter in repr, which defines max number of > symbols we want to evaluate during repr for this object. > Maybe repr is not the best here, because that should be interpreter > meaningful, but instead the __str__ method that's better for this. Maybe we > could pass in an optional limit argument to these methods, so that the user > can decide what to print depending on how many characters he has left? > > Any takes, better ideas how we could help this problem? > > Thanks, > > Bernat > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/O7TCM7F4XQAMAQJ43C6SAVKC7M2C4QHR/ > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/ZEEM4G7SFWLAOZ324UYOSH3U7IOZOB2J/ Code of Conduct: http://python.org/psf/codeofconduct/