Return value usage

2009-04-29 Thread Zac Burns
I would like to know when my function is called whether or not the return value is used. Is this doable in python? If it is, can it ever be pythonic? The use case is that I have functions who's side effects and return values are cached. I would like to optimize them such that I don't have to

Re: Return value usage

2009-04-29 Thread Simon Brunning
2009/4/29 Zac Burns zac...@gmail.com: I would like to know when my function is called whether or not the return value is used. Is this doable in python? If it is, can it ever be pythonic? AFAIK, no, it's not. The use case is that I have functions who's side effects and return values are

Re: Return value usage

2009-04-29 Thread Zac Burns
On Wed, Apr 29, 2009 at 10:14 AM, Simon Brunning si...@brunningonline.net wrote: 2009/4/29 Zac Burns zac...@gmail.com: Why not return a proxy, and have the proxy do the retrieval of the needed data if it's used? Delegation is ridiculously easy in Python. Interesting idea. I like it. I've

Re: Return value usage

2009-04-29 Thread MRAB
Zac Burns wrote: I would like to know when my function is called whether or not the return value is used. Is this doable in python? If it is, can it ever be pythonic? It doesn't sound Pythonic to me. The use case is that I have functions who's side effects and return values are cached. I

Re: Return value usage

2009-04-29 Thread Zac Burns
The point of caching is that it lets you retrieve a result cheaply that was expensive to produce by saving the result in case it's needed again. If the caching itself is expensive because it requires network access then, IMHO, that's not proper caching! (You would need a 2-level cache, ie a

Re: Return value usage

2009-04-29 Thread MRAB
Zac Burns wrote: The point of caching is that it lets you retrieve a result cheaply that was expensive to produce by saving the result in case it's needed again. If the caching itself is expensive because it requires network access then, IMHO, that's not proper caching! (You would need a 2-level