(original) (raw)
On 14 September 2017 at 23:02, Ivan Levkivskyi <levkivskyi@gmail.com> wrote:
On 14 September 2017 at 22:07, Ethan Furman <ethan@stoneleaf.us> wrote:For comparison's sake, what would the above look like using \_\_class\_\_ assignment? And what is the performance difference?
FWIW I found a different solution:# file mod.pyfrom typing\_extensions import allow\_forward\_referencesallow\_forward\_references()from mod import Vertex, Edge # the import is from this same module.It works both with \_\_class\_\_ assignment and with \_\_getattr\_\_--Ivan
Anyway, I don't think we should take this seriously, the way forward is PEP 563,
we should have clear separation between runtime context and type context. In the latter
forward references are OK, but in the former, they are quite weird.
--
Ivan