weakrefs

  • Thread starter William Trenker
  • Start date
W

William Trenker

I'm trying to get a better grasp on the difference between weakref.ref and weakref.proxy.

I've read PEP 205 and goolged for additional description information on weakrefs, but I'm not finding much. The docs for the weakref module includes the line "XXX -- need to say more here!".

Can anyone point me to tutorials or examples that illustrate where and why one would use a proxy instead of a ref?

Thanks,
Bill
 
M

Martin v. =?iso-8859-15?q?L=F6wis?=

William Trenker said:
Can anyone point me to tutorials or examples that illustrate where
and why one would use a proxy instead of a ref?

It's very easy: If you want the weakref to be used transparently in
place of the original object, you use a proxy - it tries to emulate,
by delegation, all attributes to the underlying objects. If you can
accept an explicit dereference operation throughout, you use a ref.

Regards,
Martin
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,172
Messages
2,570,933
Members
47,473
Latest member
ChristelPe

Latest Threads

Top