Christian Louboutin shoesThere could be the shinny leather, which is a little stiff a
Christian Louboutin shoesThere could be the shinny leather, which is a little stiff and would not be very soft to feel next to the skin. The matt finished leather would be less shinny and would be a little softer. This kind of leather would have a lot of variations and qualities available. Suede would be another one which would not only feel nice along the skin but its outer surface would be very soft and would give a delicate over all look.?2011 discount Christian Louboutin Large beach and plank roads area produced a wide place one can get married. All the hotels and restaurants lining plank roads it’s easy to get ready to nearby, popular until your guests gathered up, say you “I Dos” on the beach, you and your guests can go near to any number of wedding location. This is more popular area person if you have your wedding at sunset, don’t surprised to find different people, stop, and see the festivities, because they will. If someone from your plans to marry, they often will introduce you, they become christian louboutin zappos. And when you kiss, cheers and clapping start to happen. It’s very interesting. Just continue to south you’ll hit Dewey beaches, bethany beach, Fenwick island. All the great the beach 1 and beautiful route easy to find. Parking is usually not a problem, there are still many possible wedding location close by. -- http://mail.python.org/mailman/listinfo/python-list
Re: Guido rethinking removal of cmp from sort method
Steven D'Aprano wrote: > On Fri, 25 Mar 2011 10:21:35 +0100, Antoon Pardon wrote: > The reason Guido is considering re-introducing cmp is that somebody > at Google approached him with a use-case where a key-based sort did > not work. The use-case was that the user had masses of data, too > much data for the added overhead of Decorate-Sort-Undecorate (which > is what key does), but didn't care if it took a day or two to sort. > > So there is at least one use-case for preferring slowly sorting > with a comparison function over key-based sorting. I asked if there > any others. It seems not. That is one use case for preferring cmp. Another use case is "I can easily think of how to write the cmp function and not the key function and I don't care about either speed or memory usage". There's more to practicality than code execution speed. -- --OKB (not okblacke) Brendan Barnwell "Do not follow where the path may lead. Go, instead, where there is no path, and leave a trail." --author unknown -- http://mail.python.org/mailman/listinfo/python-list
Re: Guido rethinking removal of cmp from sort method
On Fri, 25 Mar 2011 16:04:02 -0700, Carl Banks wrote: > On Mar 25, 3:06 pm, Steven D'Aprano [email protected]> wrote: > > The reason Guido is considering re-introducing cmp is that somebody at > > Google approached him with a use-case where a key-based sort did not > > work. The use-case was that the user had masses of data, too much data > > for the added overhead of Decorate-Sort-Undecorate (which is what key > > does), but didn't care if it took a day or two to sort. > > > > So there is at least one use-case for preferring slowly sorting with a > > comparison function over key-based sorting. I asked if there any > > others. It seems not. > 1. You asked for a specific kind of use case. Antoon gave you a use > case, you told him that wasn't the kind of use case you were asking for, > then you turn around and say "I guess there are no use cases" (without > the mentioning qualification). That is astonishing. Did you read my post before going on the attack? I know that there is a grand tradition of adversarial argument on Usenet, but I am not your enemy here. First you wrongly accuse me of stating that there are no use cases, without qualification, when the very text you quote has me giving a use- case. Nor did I say there are no use cases -- I said that I didn't think there were any *others*. You even quote me saying this! Then you go on to wrongly claim: > 3. You evidently also overlooked the use-case example posted on Python- > dev that you followed up to. No, I did not overlook it. I explicitly described it twice. Once in the very text you quoted above, and once early in the thread when I wrote: "Guido himself has mentioned one such good use for a comparison function when sorting. Use of a key function trades off memory for time, while sorting with a comparison function makes the opposite trade off, using more time for the sake of saving memory." > 2. I posted two use cases in this thread that fit your criteria, and you > followed up to that subthread so you most likely read them. Here they > are again so you won't overlook them this time: > > "You have are given an obscure string collating function implented in a > C library you don't have the source to." (Fits your criterion "can't be > done with key=".) I must admit I don't understand this use-case. What is a string collating function, and what does this have to do with sorting? I could try to guess from the plain English meaning of the words, but if I get it wrong, that wouldn't be fair to you. Perhaps an example would help. > "I'm sitting at an interactive session and I have a convenient cmp > function but no convenient key, and I care more about the four minutes > it'd take to whip up a clever key function or an adapter class than the > 0.2 seconds I'd save to on sorting time." (Fits your criterion > "performs really badly when done so".) "I can't be bothered to write a key function" is not equivalent to "I have a key function, but it is too slow to use". In any case, from Python 3.2 onwards, a key function is never more than one import and one function call away. (In 3.1, you're stuck writing your own adapter, but in 3.1 sort doesn't take a cmp function anyway, so either way you're stuck. The earliest it could be reintroduced, if at all, is in 3.3.) > Call me crazy, but you seem to be overlooking a lot of things in your > zeal to prove your point. And what point would that be? Carl, anybody could have asked the question I have asked. Anyone is free to summarize the best of the arguments -- or all of them -- and post them to python-dev. If you think I have some ulterior motive in doing this, please feel free to champion the cmp argument to python-dev instead. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
xmlrpclib fault 8002
I Sonal Dolas work on python for project.
We connect to server as follows:
*self.server = xmlrpclib.Server("http://localhost:7081";, allow_none=True)*
I get following errror when the particular file is run:
* File "/usr/lib/python2.6/xmlrpclib.py", line 1199, in __call__*
*return self.__send(self.__name, args)*
* File "/usr/lib/python2.6/xmlrpclib.py", line 1489, in __request*
*verbose=self.__verbose*
* File "/usr/lib/python2.6/xmlrpclib.py", line 1253, in request*
*return self._parse_response(h.getfile(), sock)*
* File "/usr/lib/python2.6/xmlrpclib.py", line 1392, in _parse_response*
*return u.close()*
* File "/usr/lib/python2.6/xmlrpclib.py", line 838, in close*
*raise Fault(**self._stack[0])*
*xmlrpclib.Fault: *
--
http://mail.python.org/mailman/listinfo/python-list
Re: Writing to a file
On Fri, 25 Mar 2011 19:39:11 -0600, Littlefield, Tyler wrote: > >with open(test_absname, 'w') as test: > what's the difference in that and test = ...? I can see why you mentioned > the os.path for cross-platform, but I don't understand why someone would > use with over =. Using "with" will automatically close the the file upon exit from the block, whether by reaching the end of the block, return/break/continue, an exception, etc. -- http://mail.python.org/mailman/listinfo/python-list
Re: C Callback Function using ctypes
On Sat, 26 Mar 2011 05:23:27 +0300, OJ wrote: > Hi I am opening a shared library which has defined the following > callback prototype: > extern void DebugMessage(int level, const char *message, ...); > > My implementation in Python looks like this: > DEBUGFUNC = ctypes.CFUNCTYPE(None, ctypes.c_int, > ctypes.POINTER(ctypes.c_char)) > def DebugMessage(lvl, msg): > print lvl, msg > return > debug_callback = DEBUGFUNC(DebugMessage) > > Which gives me the following when running my python script: > 0 > How can I get something useful? 1. Use c_char_p instead of POINTER(c_char). 2. Use msg.value to obtain a Python string from the pointer. -- http://mail.python.org/mailman/listinfo/python-list
Re: C Callback Function using ctypes
On 26 March 2011 12:55, OJ wrote: >> 1. Use c_char_p instead of POINTER(c_char). >> 2. Use msg.value to obtain a Python string from the pointer. >> > > If I change to c_char_p, my program segfaults. > > If I use msg.value, I get this error message: > Traceback (most recent call last): > File "_ctypes/callbacks.c", line 295, in 'calling callback function' > File "./core.py", line 54, in DebugMessage > print lvl, msg.value > AttributeError: 'LP_c_char' object has no attribute 'value' > -- http://mail.python.org/mailman/listinfo/python-list
Re: why memoizing is faster
On Mar 26, 5:10 pm, Terry Reedy wrote: > On 3/26/2011 12:17 AM, Stefan Behnel wrote: > > > Not "restarted" in the sense that it gets cleaned up, though. The above > > simply passes an explicit value for it that will be used for the single > > call. > > Which satisfies the time test need, but... > > > Future calls won't be affected. > > Good point. If one does fib(1) and wants to dump the cache without > dumping all references to the function object, one can currently do > fib_iter.__kwdefaults__['_cache'] = [0,1] > to truly reset the cache, at least with CPython. Alternatively: new_cache = [0, 1] fib_iter(100, new_cache) fib_iter(200, new_cache) -- http://mail.python.org/mailman/listinfo/python-list
Re: why memoizing is faster
Stefan Behnel writes: > > Not "restarted" in the sense that it gets cleaned up, though. The > above simply passes an explicit value for it that will be used for the > single call. Future calls won't be affected. > > Stefan About this global caching thing I thought, but isn't this a source of possible HUGE memory leaks? I mean, when is the object _cache freed from the memory? >From my understanding until the function name is in the scope that object will never be freed, is that correct? -- http://mail.python.org/mailman/listinfo/python-list
Re: Guido rethinking removal of cmp from sort method
On Mar 25, 2:00 pm, Stefan Behnel wrote: > Westley Martínez, 25.03.2011 14:39: > > > On Fri, 2011-03-25 at 07:11 +0100, Stefan Behnel wrote: > >> Steven D'Aprano, 25.03.2011 06:46: > >>> On Thu, 24 Mar 2011 18:32:11 -0700, Carl Banks wrote: > > It's probably the least justified builtin other than pow. > > >>> I don't know about that. Correctly, efficiently and *quickly* > >>> implementing the three-argument version of pow is exactly the sort of > >>> thing that should be in the built-ins, or at least the standard library. > > >> I think that touches it already. We have a "math" module, so why is there a > >> *builtin* for doing special math? How much code is there really that only > >> uses pow() and does not import "math"? > > > pow() and math.pow() are different. > > I don't find that a good excuse for pow() being a builtin. Why not just > rename it to "math.powmod" instead? +1 (modulo bikeshedding about the name). I've long thought that three- argument pow belongs in the standard library rather than the core. And then the existence of the ** operator obviates the need for two- argument pow. Worse than pow itself is the fact that the __pow__ special method takes an optional 3rd argument, which apart from unnecessarily complicating Python's internal, also leads to horrors like Decimal's (IMO inappropriate) support for 3-argument pow. -- Mark -- http://mail.python.org/mailman/listinfo/python-list
Free Software University - Python Certificate - In reply to Noah Hall
Noah Hall enalicho at gmail.com Tue Mar 22 17:38:48 CET 2011 >I've been following this project for a while, since it was annouced on the Ubuntu forums. I can't say that I've been at all impressed by anything they have to offer. Hi Noah, I'm interested in your post for a few reasons: 1. There is no Noah Hall registered in the FSU 2. Your email address is not registered in the FSU 3. The FSU is really about what _you_ have to offer 4. As has already been noted, we are currently making courses 5. The first course (Free Software Certificate) starts 2nd May 2011 ..so, maybe you can help me to understand your post? It seems a strange post, based on these facts... Maybe you'd like to come along and actually get involved? You would be most welcome.. our other 800 members will be happy to see you, I'm sure... come and contribute! :) Lloyd FSU Founder -- http://mail.python.org/mailman/listinfo/python-list
Re: why memoizing is faster
On Sat, 26 Mar 2011 12:06:46 +0100, Andrea Crotti wrote:
> About this global caching thing I thought, but isn't this a source of
> possible HUGE memory leaks?
Hypothetically, but probably not that huge. And I wouldn't call it a
*leak* as such, since you can access the memory and recover it if you
want to.
The cache given is potentially unbounded in size, but in practical terms,
it's unlikely to get that big. Say you have a few million key:value pairs
in a dict:
>>> d = {}
>>> for i in range(300):
... d[i] = 2**100 + i
...
>>> sys.getsizeof(d)
100663432
>>> sum(sys.getsizeof(k)+sys.getsizeof(v) for k,v in d.items())
125934462
That's of the order of 200 MB of memory -- not that much for today's
systems. I've had people email me .doc files that big *wink*
But of course, if you want a more sophisticated caching system, you can
build one. But this will trade off memory for time: the cache will be
slower, there will be more misses, but you won't use as much memory.
> I mean, when is the object _cache freed from the memory?
When the function is freed, which will happen at program exit, or if you
explicitly delete the function.
--
Steven
--
http://mail.python.org/mailman/listinfo/python-list
Re: Writing to a file
On Sat, 26 Mar 2011 14:49:31 +1300, Gregory Ewing wrote: > [email protected] wrote: > >import os >os.system('echo "Testing a... b... c..." > "~/Desktop/test2.txt"') > > This is like going out the back door, getting a ladder out of the shed > and climbing through your bedroom window to get into bed at night, > instead of just using the stairs. > > Use open/write/close. It's much more direct and efficient. I would say the analogy is more like calling the local handyman to come to your house and get the ladder for you. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
[ANN] Shed Skin 0.7.1
hi all, I have just released Shed Skin 0.7.1, an optimizing (restricted!) Python-to-C++ compiler. It comes with some important extension module fixes, optimizations for several builtins (zip, min, max, map, filter, reduce, pow), a warning for non-uniform tuples of length > 2 and some minor fixes and internal cleanups. There are also two nice new examples (a quantum monte carlo simulator and an rsync implementation), bringing the count to 54 example programs, for a total of around 15,000 lines of code (as measured by sloccount). Please see my blog for the full announcement: http://shed-skin.blogspot.com Or go straight to the homepage: http://shedskin.googlecode.com Please have a look at the tutorial, try it out, and file any problems in the issue tracker. I'm also always very interested in hearing about potential new programs to add to the example set! Thanks, Mark Dufour -- http://www.youtube.com/watch?v=E6LsfnBmdnk -- http://mail.python.org/mailman/listinfo/python-list
Re: best python games?
sogeking99 writes: > hey guys, what are some of the best games made in python? free games > really. like pygames stuff. i want to see what python is capable of. Apparently Eve Online is (stackless) python. -- http://mail.python.org/mailman/listinfo/python-list
Re: dynamic assigments
On 03/24/2011 07:39 PM, Seldon wrote: Hi, I have a question about generating variable assignments dynamically. I have a list of 2-tuples like this ( (var1, value1), (var2, value2), .. , ) where var1, var2, ecc. are strings and value1, value2 are generic objects. Now, I would like to use data contained in this list to dynamically generate assignments of the form "var1 = value1", ecc where var1 is an identifier equal (as a string) to the 'var1' in the list. Is there a way to achieve this ? Thanks in advance for any answer. Thanks to everybody for yours interesting considerations. Regarding my initial problem, I understood that using a dictionary mapping variable names to values probably is the best approach. -- http://mail.python.org/mailman/listinfo/python-list
Hello Friends
For Biography of Bollywood actresses just visit www.hothitsbollywood.blogspot.com Here Just for You Aiswarya Rai Aishwarya Rai Biography Ash Ash Baby Aishwarya Krishnaraj Rai was born on 1 November 1973 in Mangalore. Her father Krishnaraj Rai was a marine engineer and her mother Vrinda Rai is a writer. She has an older brother Aditya Rai who is in the merchant navy. He also happened to co-produce Dil Ka Rishta in 2003, which starred Ash. The family moved to Mumbai where she studied at the Arya Vidya Mandir and later moved to Ruparel College. She was aspiring to study architecture but that did not take off while her career in the glamour industry took off. Ash won the coveted Miss World crown in 2004. Soon after this she pledged to donate her eyes after her death. She went on to become the brand ambassador for brands like L’Oreal, Pepsi, and Coco Cola. She struck a pose for many international magazines like TIME and was also voted one of the most attractive and influential women by several polls. She is the first Indian actor to be part of the jury at the prestigious Cannes Film Festival. She has appeared in The Oprah Winfrey Show, Late Show with David Letterman, and 60 Minutes. She was also the first Indian actress to be replicated in wax at Madame Tussaud’s Museum in London. She was briefly involved with actors Salman Khan and Vivek Oberoi before marrying actor Abhishek Bachchan, son of the iconic Amitabh Bachchan and Jaya Bachchan. They were married in 2007. The couple have acted together in many movies. They were seen in the latest Lux ad and have been roped in to be part of PETA’s Lovebirds campaign. The Rai Magic Aishwarya began her career in the film industry with a Tamil film Iruvar in 1997 which was a hit as opposed to her Hindi film Aur Pyaar Ho Gaya with Bobby Deol. She won the Filmfare Best Actress Award for her next Tamil film Jeans, which was also an entry to the Oscars. In 1999, she gained recognition in Bollywood with hits like Taal and Hum Dil De Chuke Sanam, in which she played opposite Salman Khan and Ajay Devgan, her role as Nandini fetching her the Filmfare Best Actress Award. In 2000, her Tamil film Kandukondain Kandukondain, saw a good turnout. She took on the role of Shirley, Shahrukh Khan’s sister in Josh and then played his love interest in Mohabbatein which won her a nomination for the Filmfare Best Supporting Actress Award. In Hamara Dil Aapke Paas Hai, she played Preeti Virat, a rape victim and was considered for the Filmfare Best Actress Award. The year 2001 was a quiet year for Ash. Sanjay Leela Bhansali’s Devdas (2002), in which she played Paro with Shahrukh Khan and Madhuri Dixit, was an instant blockbuster. It also received a special screening at the Cannes Film Festival. She won the Filmfare Best Actress award. In 2003, she acted the part of Binodini in a Bengali film Choker Bali which was based on a novel by Rabindranath Tagore. The film was nominated for the Golden Leopard at the Locarno International Film Festival. The year 2004 saw Ash in her first English film, Gurinder Chaddha’s Bride & Prejudice, an adaptation of Jane Austen’s Pride & Prejudice. Her performance as Neerja in Rituparno Ghosh’s Raincoat was praised. This was followed by her second English film in 2005, The Mistress of Spices, with Dylan McDermott of The Practice fame. Her dance sequence Kajra Re from Bunty Aur Babli became one of the most popular tunes of the year. She had two films out in 2006. Umrao Jaan with Abhishek Bachchan failed to do well while Dhoom 2 where she played Sunehri and shared a ‘controversial’ liplock with Hrithik Roshan was a big hit. In 2007, she played Sujata opposite Abhishek Bachchan in Guru, based on the industrialist Dhirubhai Ambani and it was successful. Provoked, which was based on a real episode of domestic violence, won critical acclaim. The other English film, The Last Legion, did not do so well. Jodhaa Akbar, released in 2008, in which she acted the part of Jodhaa Bai with Hrithik Roshan was average. The sequel to Sarkar, Ram Gopal Varma’s Sarkar Raj, in which she plays a CEO alongside Amitabh Bachchan and Abhishek Bachchan, is said to be one of her best performances till date. In 2009, Rai looked her gorgeous self in The Pink Panther 2 with Steve Martin. Going Strong She was also busy shooting for Mani Ratnam’s Raavan with Abhishek Bachchan and Endhiran with Rajnikanth in 2009. Both movies will be released in 2010 along with Action Replay with Akshay Kumar and Guzaarish, in which she will play Hrithik Roshan’s nurse. -- http://mail.python.org/mailman/listinfo/python-list
Re: why memoizing is faster
On Saturday, March 26, 2011 7:50:36 AM UTC-4, Steven D'Aprano wrote: > > That's of the order of 200 MB of memory -- not that much for today's > systems. I've had people email me .doc files that big *wink* Yikes! I know this thread is about caching the output of a function, but in the example of Fibonacci numbers, we're blessed with an easily derived closed form expression (via Z transform, etc): def fib(n): phi = (5 ** 0.5 + 1) / 2 f = (phi ** n - (1 - phi) ** n) / 5 ** 0.5 return int(f) -- http://mail.python.org/mailman/listinfo/python-list
Re: why memoizing is faster
On Sat, 26 Mar 2011 07:14:17 -0700, eryksun () wrote: > On Saturday, March 26, 2011 7:50:36 AM UTC-4, Steven D'Aprano wrote: >> >> That's of the order of 200 MB of memory -- not that much for today's >> systems. I've had people email me .doc files that big *wink* > > Yikes! I know this thread is about caching the output of a function, but > in the example of Fibonacci numbers, we're blessed with an easily > derived closed form expression (via Z transform, etc): > > def fib(n): > phi = (5 ** 0.5 + 1) / 2 > f = (phi ** n - (1 - phi) ** n) / 5 ** 0.5 return int(f) Have you tried it? Unfortunately, with floating point rounding error, that rapidly becomes inaccurate. It gives: >>> fib(72) 498454011879265 compared to the correct value of 498454011879264 (an error of 1) and rapidly gets worse. It's true that the above formula is correct for real numbers, but floats are not reals. Unless you have an infinite number of decimal places, it will be inaccurate. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Which subversion interface is the most used one?
Hi, at one of our projects, we could make use of a subversion interface for IronPython. But there seems none to exist. The easiest way would be to directly expose SharpSVN to the IronPython scripts, but that is not a very pythonic solution. So we had the Idea of porting the existing python interfaces to IronPython. And here the confusion starts, there seem to exist at least three of them (those are the ones I found being prepackaged on debian): python-subversion: Seems to be a rather autogenerated wrapper around libsvn - thus being feature-complete, but rather unpythonic. python-svn (pysvn): Seems to be written in C++, and give a somehow pythonic interface to the most important functionality. python-subvertpy: Seems to aggregate the advantages of the two previous solutions, but I did not find any API documentation. It seems that porting one of them to IronPython in a 1:1 fashion is no feasible solution. So I came up with the Idea of simply re-implementing the API of one of those packages in C#, in a way that it can be exposed as IronPython module, using SharpSVN or Monodevelop-VersionControl as backend. This seems to be a rather low cost way of providing subversion functionality to IronPython, in a way compatible with at least some of the cPython Subversion applications. Now my question: Which one of the SVN interfaces are established and broadly used? I don't want to risk to put effort into implementing a dead API when others are alive. I have a slight tendency to pysvn, as it seems to be well documented and pythonic. Thanks for your comments. Markus -- Probleme kann man niemals mit derselben Denkweise lösen, durch die sie entstanden sind. (Albert Einstein) -- http://mail.python.org/mailman/listinfo/python-list
Re: why memoizing is faster
On 3/26/2011 5:55 AM, Lie wrote: On Mar 26, 5:10 pm, Terry Reedy wrote: On 3/26/2011 12:17 AM, Stefan Behnel wrote: Not "restarted" in the sense that it gets cleaned up, though. The above simply passes an explicit value for it that will be used for the single call. Which satisfies the time test need, but... > Future calls won't be affected. Good point. If one does fib(1) and wants to dump the cache without dumping all references to the function object, one can currently do fib_iter.__kwdefaults__['_cache'] = [0,1] to truly reset the cache, at least with CPython. Alternatively: new_cache = [0, 1] fib_iter(100, new_cache) fib_iter(200, new_cache) No, that is not an alternative to what I wrote ;-). As Stefan pointed out above, passing a value to over-ride a default only substitutes for the default in that one call. It is like a temporary substitute teacher. It does not replace the default in the function object. The assignment I give above is like a permanent replacement teacher. The previous cache list will be garbage collected. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: why memoizing is faster
On Saturday, March 26, 2011 11:49:02 AM UTC-4, Steven D'Aprano wrote: > > > > def fib(n): > > phi = (5 ** 0.5 + 1) / 2 > > f = (phi ** n - (1 - phi) ** n) / 5 ** 0.5 > > return int(f) > > Have you tried it? > > Unfortunately, with floating point rounding error, that rapidly becomes > inaccurate. It gives: > > >>> fib(72) > 498454011879265 > > compared to the correct value of 498454011879264 (an error of 1) and > rapidly gets worse. It's true that the above formula is correct for real > numbers, but floats are not reals. Unless you have an infinite number of > decimal places, it will be inaccurate. That's true. If you need more than double precision, obviously it's time to defer to the experts. Here's an O(n) algorithm: http://www.gnu.org/software/gmp/manual/html_node/Fibonacci-Numbers-Algorithm.html This library is wrapped by the gmpy extension module: http://code.google.com/p/gmpy I was just shocked to see 200 MB of memory used up like chump change, and I immediately looked for an alternative. In practice, I prefer to rely on libraries created by specialists who have carefully worked out the best trade-offs for typical use, and puzzled through the algorithms needed to compute that which is so easy to derive on paper (such as my simple little Z-transform derived formula that fails so wonderfully in practice). I'm not a computer scientist; I don't even play one on TV. -- http://mail.python.org/mailman/listinfo/python-list
Re: why memoizing is faster
On 3/26/2011 7:06 AM, Andrea Crotti wrote: Stefan Behnel writes: Not "restarted" in the sense that it gets cleaned up, though. The above simply passes an explicit value for it that will be used for the single call. Future calls won't be affected. Stefan About this global caching thing I thought, but isn't this a source of possible HUGE memory leaks? The original decorator that used one dictionary for possibly caching multiple functions could certainly cause memory problems. It would not disappear until the decorator and all wrapped functions were gone. I mean, when is the object _cache freed from the memory? From my understanding until the function name is in the scope that object will never be freed, is that correct? You mean 'while the function name...'. And yes, correct, unless one used the trick I posted in response to Stefen: fib_iter.__kwdefaults__['_cache'] = [0,1] The point of this might be to free a cache swollen by a one-time call with a large n, without deleting the function itself. One could then continue with calls using normal-sized ints. Caching is a time-space tradeoff that might need tuning to a particular application. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Guido rethinking removal of cmp from sort method
On 3/26/2011 4:49 AM, Steven D'Aprano wrote: On Fri, 25 Mar 2011 16:04:02 -0700, Carl Banks wrote: Call me crazy, I would call you a bit ungrateful. Steven could have stayed silent instead of making himself a target by informing interested people on this list about the pydev post by Guido. >> but you seem to be overlooking a lot of things in your zeal to prove your point. The only point I have seen him 'push' it that it will take a good argument to move Guido (and other developers) from 'possibly' to "I (we) made a mistake. Let's revert." Don't shoot the messenger. And what point would that be? That you like Python and want to see it improved even further, as do I ;-). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
FW: ciao
3. Scrivere una funsion che prende come argomento una lista di interi e restituisce uninsieme contenente quei numeri che sono 2 o più volte nella lista fornita. Per esempio,se serve come lista di input = [1,2,3,3,4,4,5,6,7,7,7], quindi la funzione restituirà il set([3,4,7]) Mi puoi aiutare a fare questo programma a python Grazie -- http://mail.python.org/mailman/listinfo/python-list
Re: [SPAM] FW: ciao
On 26/03/2011 18:07, bledar seferi wrote: 3.Scrivere unafunsioncheprende comeargomentouna lista diinterierestituisce uninsieme contenentequei numerichesono2 o più voltenellalista fornita.Per esempio,seservecomelista di input=[1,2,3,3,4,4,5,6,7,7,7],quindila funzionerestituiràilset([3,4,7]) Mi puoi aiutare a fare questo programma a python Grazie I'd use a defaultdict to count them. -- http://mail.python.org/mailman/listinfo/python-list
Re: why memoizing is faster
On 3/26/2011 11:49 AM, Steven D'Aprano wrote: On Sat, 26 Mar 2011 07:14:17 -0700, eryksun () wrote: Yikes! I know this thread is about caching the output of a function, but in the example of Fibonacci numbers, we're blessed with an easily derived closed form expression (via Z transform, etc): def fib(n): phi = (5 ** 0.5 + 1) / 2 f = (phi ** n - (1 - phi) ** n) / 5 ** 0.5 In the real number system, the above is the exact integer. >> return int(f) In the real number system, this would by a pure type cast, with no truncation. In the float system, where, in general, answers could be a bit too small as well as too big, rounding might be better. If one truncates real numbers, there is no need (except for fib(0)) to subtract (1-phi)**n as that is always less than 1 (except for fib(0)). However.. Have you tried it? I have been thinking about it. Thanks for doing it ;-). Unfortunately, with floating point rounding error, that rapidly becomes inaccurate. It gives: fib(72) 498454011879265 compared to the correct value of 498454011879264 (an error of 1) and rapidly gets worse. So it appears that float_phi > real_phi, so that the powers get increasingly too large with n. Even without thisproblem, Rounding would happen anyway as soon as fib(n) had 18 digits (for standard 8-byte floats). If one uses fib(n) in a floating point calculation, the error might not matter, but if one is verifying any of the existing exact equality theorems or searching for a new one, exact values are necessary. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
simple problem with jpype on WindowsXP
Hi, I've got some kind of install problem with jpype ... It should just work, but throws a dialog exception, that doesn't give a stack trace so not very helpful. This should be a simple install issue, but I've searched and haven't seen any thing import jpype p = jpype.getDefaultJVMPath() jpype.startJVM(p, "-ea") # I choke on the startJVM ... JVM path is correct, I have no issue with Java 1.6 installed jpype: JPype-0.5.4.win32-py2.7.exe windows Python 2.7 ActivePython 2.7.0.2 (ActiveState Software Inc.) based on Python 2.7 (r27:82500, Aug 23 2010, 17:18:21) [MSC v.1500 32 bit (Intel)] on win32 -- http://mail.python.org/mailman/listinfo/python-list
Re: Guido rethinking removal of cmp from sort method
(Trying again to get through to python-list) On Sat, Mar 26, 2011 at 2:10 AM, Steven D'Aprano wrote: > > Dan Stromberg wrote: > > There's also the issue of a lazy comparison function, that I don't seem to >> have gotten a response to - if you have a Very expensive comparison >> operation involving megabytes or even gigabytes of data, and want to >> perform >> just enough of it to get the job done, how does one do this with a key >> comparator and no cmp comparator? >> > > > Okay, that's a reasonable use-case: lazy comparisons. Thank you. > And thank you. > [...] > > (The version at the following URL might be a little newer) >> >> http://stromberg.dnsalias.org/cgi-bin/viewvc.cgi/equivalence-classes/trunk/equivs2-python/?root=svn >> > > > By the way, you have a logic error in that code. You state: > > > # if we were asked not to do full comparisons, just trust the result so far > - don't do the ultra-expensive > # "compare every single byte" procedure > > But that is *cheaper* that a cryptographic hash. The crypto hash still has > to look at every byte, but rather than just compare two bytes, it slices and > dices them using a very expensive cryptographically secure hash function. > Nor can you bail out early if you find mismatched bytes. The hash functions > have to read every single byte before returning. > It might be the surrounding context that makes the difference. For comparing two files, byte for byte is always cheaper, or at worst the same expense when the files are equal. For comparing 1,000,000 files, each to all the other 999,999, the cryptographic hash is probably cheaper in most cases. Even when the files are all local. > BUFFERSIZE = 256*1024 # 256K > > def file_compare(a, b, buffersize=None): >"""file_compare(a, b [, buffersize]) -> int status code > >Compare files with names a and b, and return an integer status code: > 0 the files are different > 1 the filenames refer to the same physical location in the file > system, e.g. a='./file.txt' and b='./dir/../file.txt' > 2 the filenames refer to a single hardlinked file > 3 the filenames refer to distinct files with identical contents > >""" >a = os.path.normcase( os.path.normpath(a) ) >b = os.path.normcase( os.path.normpath(b) ) >if a == b: # Same file name after normalisation. >assert os.path.samefile(a, b) >return 1 >elif ishardlink(a, b): >assert os.path.samefile(a, b) >return 2 >assert not os.path.samefile(a, b) >if file_equals(a, b, buffersize): >return 3 >return 0 > > > def ishardlink(a, b): >"""ishardlink(a, b) -> True|False > >Return True if filenames a and b are the same hardlinked file, >otherwise False. >""" >s1 = os.stat(a) >s2 = os.stat(b) >return (s1.st_ino, s1.st_dev) == (s2.st_ino, s2.st_dev) > > > def file_equals(a, b, buffersize=None): >"""file_equals(a, b[, buffersize]) -> True|False > >Return True if files with names a and b have the same content, >otherwise return False. > >Files a and b are equal if every byte in the files match. >""" >if os.path.getsize(a) != os.path.getsize(b): >return False >if buffersize is None: >buffersize = BUFFERSIZE >fa = open(a, 'rb') >fb = open(b, 'rb') >ba = bb = '' >while 1: >ba = fa.read(buffersize) >bb = fb.read(buffersize) >if ba != bb: >return False >elif ba == bb == '': >break >return True > > Thanks for showing me this. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with keyboard up/down arrows in Python 2.4 interpreter
On Mar 25, 6:35 pm, Ned Deily wrote: > In article > , > Benjamin Kaplan wrote: > > > As I stated above, py-readline is for if you're using Macports, which > > is a package manager for Mac OS X. > > ... in which case you probably want: > > sudo port install py-readline > > > If you installed Python through > > some other means, I'm not sure why you don't have readline installed > > already, because it should be built with the rest of the Python > > modules. > > For releases prior to Python 2.6 and Python 3.2, to build the Python > readline module, you need to have installed a local version of the GNU > readline library, a library which is not included in Mac OS X. Starting > with Python 2.6 and with a deployment target of Mac OS X 10.5 or higher, > the Python readline module will be automatically linked with the > Apple-supplied BSD editline (libedit) library. > > P.S to Julien: Python 2.4 is *really* old now and is no longer supported > by the Python developers. It probably won't build correctly on current > OS X 10.6 without some help. Python 2.7.1 and Python 3.2 are the > current releases. > > -- > Ned Deily, > [email protected] Thank you Ned and Benjamin, and sorry for the confusion :) I did install python2.4 using Mac Ports, and as you've suggested I've just installed py-readlines using Mac Ports as well, and it now works! Many thanks! Julien -- http://mail.python.org/mailman/listinfo/python-list
Re: Guido rethinking removal of cmp from sort method
On Mar 26, 4:39 am, Mark Dickinson wrote: > On Mar 25, 2:00 pm, Stefan Behnel wrote: > > > > > > > > > > > Westley Martínez, 25.03.2011 14:39: > > > > On Fri, 2011-03-25 at 07:11 +0100, Stefan Behnel wrote: > > >> Steven D'Aprano, 25.03.2011 06:46: > > >>> On Thu, 24 Mar 2011 18:32:11 -0700, Carl Banks wrote: > > > It's probably the least justified builtin other than pow. > > > >>> I don't know about that. Correctly, efficiently and *quickly* > > >>> implementing the three-argument version of pow is exactly the sort of > > >>> thing that should be in the built-ins, or at least the standard library. > > > >> I think that touches it already. We have a "math" module, so why is > > >> there a > > >> *builtin* for doing special math? How much code is there really that only > > >> uses pow() and does not import "math"? > > > > pow() and math.pow() are different. > > > I don't find that a good excuse for pow() being a builtin. Why not just > > rename it to "math.powmod" instead? > > +1 (modulo bikeshedding about the name). I've long thought that three- > argument pow belongs in the standard library rather than the core. > And then the existence of the ** operator obviates the need for two- > argument pow. IMO, there is far too much willingness to churn long-standing APIs for nearly zero benefit. In my decade as a core Python developer, I've come view deprecations as things that cause unnecessary pain for users and is partially to blame for so many organizations staying with older, unmaintained versions of Python. When it comes to moving pow() to another module or changing the signature for the __pow__ magic method, there's not much of a win to be had, but it will affect tons of existing code (including examples in printed books where pow() is commonly used in examples). I think we (as a group) need to develop a strong aversion to breaking existing APIs and instead focus on making existing APIs more robust or giving them useful extensions. The Python language is not like a personal library where changing APIs has limited (and predictable costs). Raymond -- http://mail.python.org/mailman/listinfo/python-list
Re: why memoizing is faster
On Sat, 26 Mar 2011 10:25:31 -0700, eryksun () wrote about Fibonacci function: > That's true. If you need more than double precision, obviously it's time > to defer to the experts. Here's an O(n) algorithm: > > http://www.gnu.org/software/gmp/manual/html_node/Fibonacci-Numbers- Algorithm.html We should always prefer a well-tested, well-profiled and tuned algorithm for one we just made up ourselves :) The GMP algorithm is tuned to use a small cache of (I estimate) a few hundred KB, and then uses bit-twiddling to generate higher numbers. That would be unacceptably slow in pure Python, but should be acceptable in C. But again, notice that they are trading off time for space: they care more about keeping the memory footprint small than about being fast (a luxury you can have when programming in C, where even slow things tend to be fast). [...] > I was just shocked to see 200 MB of memory used up like chump change, But it is chump change :) Seriously, your point is a very good one. If writing a function that uses a cache, the right thing to do is to have some sort of strategy for dealing with the cache and preventing it from becoming unbounded in size. The re module has a very simple-minded strategy: when the number of items in the cache hits 100, delete the lot. There are far more sophisticated strategies possible, and also an even more simple one: document the cache as part of your user interface, and leave it to the caller to manage it. But having said that, don't be scared of throwing memory at a problem to make it fast, especially in a language like Python. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Understanding the Pystone measurement
On Mar 24, 9:21 pm, "[email protected]" wrote: > Hi there, > > Is there a good writeup of what the pystone measurement actually > means? I'm working on benchmarking of some Python code at work, and > I'm interested in how Pystone might be relevant to me. I've tried > googling, but I can't find any introductory / definitional > descriptions of what this module/measurement means. Pystone provides an estimate of the relative performance of different pieces of hardware running single threaded Python apps. If your old laptop scores 12000 pystones and your new shiny macbook scores 84000, then you can expect your non-i/o bound single threaded python apps to run about seven times faster on the new machine. Raymond -- http://mail.python.org/mailman/listinfo/python-list
Re: Understanding the Pystone measurement
I forgot to mention that PyStone is just a Python translation from C of the venerable Dhrystone benchmark. See http://en.wikipedia.org/wiki/Dhrystone for a short write-up on the history, purposes, and limitations of the benchmark. Raymond -- http://mail.python.org/mailman/listinfo/python-list
Re: FW: ciao
On Mar 26, 11:34 am, MRAB wrote: > On 26/03/2011 18:07, bledar seferi wrote: > > > 3.Scrivere unafunsioncheprende comeargomentouna lista > > diinterierestituisce uninsieme contenentequei numerichesono2 o più > > voltenellalista fornita.Per esempio,seservecomelista di > > input=[1,2,3,3,4,4,5,6,7,7,7],quindila funzionerestituiràilset([3,4,7]) > > > Mi puoi aiutare a fare questo programma a python > > > Grazie > > I'd use a defaultdict to count them. Or use itertools.groupby() to group consecutive values, count the length of each group, and emit the value whenever the count is more than one: >>> s = [1,2,3,3,4,4,5,6,7,7,7] >>> [k for k, g in groupby(s) if len(list(g)) > 1] [3, 4, 7] Raymond -- http://mail.python.org/mailman/listinfo/python-list
