A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-November/093839.html below:

[Python-Dev] Retrieve an arbitrary element from a setwithoutremoving it

[Python-Dev] Retrieve an arbitrary element from a setwithoutremoving itChris Bergstresser chris at subtlety.com
Fri Nov 6 04:12:45 CET 2009
On Thu, Nov 5, 2009 at 6:30 PM, geremy condra <debatem1 at gmail.com> wrote:
> I'm testing the speed because the claim was made that the pop/add
> approach was inefficient. Here's the full quote:
>
>>    The obvious way, for newcomers, of achieving the effect is:
>>
>>  x = s.pop()
>>  s.add(x)
>>
>> ... and that's simply horrible in terms of efficiency.  So the
>> "obvious" way of doing it in Python is wrong(TM), and the "correct"
>> way of doing it is obscure and raises misleading exceptions.

   I was talking mainly from a theoretical standpoint, and because the
library I'm working on is designed to work seamlessly over the
network.  In those cases, where the set the user is working with is
actually a proxy object across the wire, the time to acquire the
locks, remove the object, release the locks, reacquire the locks, add
the object, then rerelease the locks is *significantly* more expensive
than just noting the set hasn't changed and returning a cached object
from it.

-- Chris
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4