0

I had this question for long time in my mind perhaps the time has come for asking this question.

How do we effectively use the nature of self referencing list and dictionary to our advantage.

a = []
a[:] = [a]
b = {}
b['b'] = b

If possible can anyone explain this with an example.

sathya Narrayanan
  • 499
  • 1
  • 5
  • 16
  • I don't think it very useful. You can do the same thing in C/C++ using pointers, but what good is it? You could use it as a self defined `NULL` or something if you wanted too. – Matt Jul 07 '15 at 06:31
  • What is your question really? – Pynchia Jul 07 '15 at 06:32
  • Yeah actually I guess maybe you could find a way to use it in a graph like in `metaoaster`'s post. `b` is a graph. `b` is also a subset of `b`? – Matt Jul 07 '15 at 06:34
  • @pynchia by using self referencing list or dict will it grant any improved performance over our programs. the reason i asked this question is because i have seen the source of Lib/Collections.py for ordereddict raymond is using self referencing list to build the heap of values. will it grant any performance improvement? – sathya Narrayanan Jul 08 '15 at 07:28

0 Answers0