Re: [Tutor] Why do sets use 6 times as much memory as lists?

2013-05-07 Thread wesley chun
Following Oscar's comment, It's also O(n) vs. O(1) tradeoff. --wesley On Tue, May 7, 2013 at 12:09 PM, Oscar Benjamin wrote: > On 7 May 2013 19:09, Bjorn Madsen wrote: > > Hi, Thanks for the quick response. > > > > "Being curious" I actually expected something like this: > L={x:None for x

Re: [Tutor] Why do sets use 6 times as much memory as lists?

2013-05-07 Thread eryksun
On Tue, May 7, 2013 at 9:30 PM, eryksun wrote: > >> That is why I wondered why 6 times is a lot given that a dict can do the >> same at 3/4 of the mem-footprint. I hope it's clear that 3/4 here comes from 1/2 * 3/2. In other words the dict table has 1/2 the number of entries, and each entry is 3/

Re: [Tutor] Why do sets use 6 times as much memory as lists?

2013-05-07 Thread eryksun
On Tue, May 7, 2013 at 2:09 PM, Bjorn Madsen wrote: > > "Being curious" I actually expected something like this: L={x:None for x in range(1)} sys.getsizeof(L) > 196660 > > That is why I wondered why 6 times is a lot given that a dict can do the > same at 3/4 of the mem-footprint. Jus

Re: [Tutor] Why do sets use 6 times as much memory as lists?

2013-05-07 Thread Steven D'Aprano
On 08/05/13 03:10, Bjorn Madsen wrote: import sys L=[x for x in range(1)] sys.getsizeof(L) 43816 L={x for x in range(1)} sys.getsizeof(L) 262260 ? Both sets and lists may be over-allocated. I expect that lists created with a list comprehension may not be over-allocated, but if you

Re: [Tutor] Argparse functions with N parameters

2013-05-07 Thread Mark Lawrence
On 07/05/2013 17:15, Prasad, Ramit wrote: Peter Otten wrote: [snip] There may be a library out there that does this with bells and whistles, but I haven't looked. This is not related to the OP, but have you [Peter/tutors] taken a look at the docopt library? Any thoughts compared to argparse/

[Tutor] Games from Mark Dawson#'s book

2013-05-07 Thread Stafford Baines
I recently wrote to this forum about the games downloaded from Mark Dawson's book Python Programming 3rd Edition and couldn't get the graphics games (chapters 11 and 12 of the book) to work. I had helpful and friendly advice from boB and Dave. The book has been written around python 3.1 and I

Re: [Tutor] Why do sets use 6 times as much memory as lists?

2013-05-07 Thread Oscar Benjamin
On 7 May 2013 19:09, Bjorn Madsen wrote: > Hi, Thanks for the quick response. > > "Being curious" I actually expected something like this: L={x:None for x in range(1)} sys.getsizeof(L) > 196660 > > That is why I wondered why 6 times is a lot given that a dict can do the > same a

Re: [Tutor] Why do sets use 6 times as much memory as lists?

2013-05-07 Thread Bjorn Madsen
Hi, Thanks for the quick response. "Being curious" I actually expected something like this: >>> L={x:None for x in range(1)} >>> sys.getsizeof(L) 196660 >>> That is why I wondered why 6 times is a lot given that a dict can do the same at 3/4 of the mem-footprint. Just got surprised about the

Re: [Tutor] Why do sets use 6 times as much memory as lists?

2013-05-07 Thread Oscar Benjamin
On 7 May 2013 18:10, Bjorn Madsen wrote: import sys L=[x for x in range(1)] sys.getsizeof(L) > 43816 L={x for x in range(1)} sys.getsizeof(L) > 262260 Firstly, these results may vary depending on operating system, processor architecture and build options so this w

Re: [Tutor] Why do sets use 6 times as much memory as lists?

2013-05-07 Thread Dave Angel
On 05/07/2013 01:10 PM, Bjorn Madsen wrote: import sys L=[x for x in range(1)] sys.getsizeof(L) 43816 L={x for x in range(1)} sys.getsizeof(L) 262260 ? kind regards, Bjorn Just curious: what did you expect? Sets have a different purpose, basically to be able to do an 'in' operatio

[Tutor] Why do sets use 6 times as much memory as lists?

2013-05-07 Thread Bjorn Madsen
>>> import sys >>> L=[x for x in range(1)] >>> sys.getsizeof(L) 43816 >>> L={x for x in range(1)} >>> sys.getsizeof(L) 262260 ? kind regards, Bjorn ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.

Re: [Tutor] Argparse functions with N parameters

2013-05-07 Thread Prasad, Ramit
Peter Otten wrote: [snip] > > There may be a library out there that does this with bells and whistles, but > I haven't looked. > This is not related to the OP, but have you [Peter/tutors] taken a look at the docopt library? Any thoughts compared to argparse/optparse? ~Ramit This email is con

Re: [Tutor] Argparse functions with N parameters

2013-05-07 Thread Peter Otten
Danilo Chilene wrote: > Hello, > > I have the code below: > > import argparse > class Myclass(object): > > def foo(self): > print 'foo' > > def bar(self): > print 'bar' > > def test(self,name,place): > print name, place > > class Main(Myclass): > def _

[Tutor] Argparse functions with N parameters

2013-05-07 Thread Danilo Chilene
Hello, I have the code below: import argparse class Myclass(object): def foo(self): print 'foo' def bar(self): print 'bar' def test(self,name,place): print name, place class Main(Myclass): def __init__(self): foo_parser = argparse.ArgumentParser

Re: [Tutor] Text Editors and Linux (was Re: exit message)

2013-05-07 Thread Prasad, Ramit
Steven D'Aprano wrote: > * a decent console app that supports multiple tabs; Any reason to prefer tabs to virtual terminals (i.e. screen)? ~Ramit This email is confidential and subject to important disclaimers and conditions including on offers for the purchase or sale of securities, accuracy