Re: Converting a string to an array?

2006-01-13 Thread Tim Peters
[Bryan Olson] > ... > For sorting, we had the procedure 'sort', then added the pure > function 'sorted'. We had a 'reverse' procedure, and wisely > added the 'reversed' function. > > Hmmm... what we could we possible do about 'shuffle'? 'permuted' is the obvious answer, but that would leave us ope

Re: Just want to walk a single directory

2006-01-14 Thread Tim Peters
[EMAIL PROTECTED] > I have a super-simple need to just walk the files in a single directory. > > I thought this would do it, but "permanentFilelist" ends up containing > all folders in all subdirectories. All folders everywhere, or all file (not directory) names in the top two levels? It looks li

Re: More than you ever wanted to know about objects [was: Is everything a refrence or isn't it]

2006-01-15 Thread Tim Peters
[Alex Martelli] ... >> In mathematics, 1 is not "the same" as 1.0 -- there exists a natural >> morphism of integers into reals that _maps_ 1 to 1.0, but they're still >> NOT "the same" thing. And similarly for the real-vs-complex case. [Xavier Morel] > I disagree here, 1 and 1.0 are the same math

Re: OT: excellent book on information theory

2006-01-16 Thread Tim Peters
[Paul Rubin] ... >> David J.C. MacKay >> Information Theory, Inference, and Learning Algorithms >> >> Full text online: >> http://www.inference.phy.cam.ac.uk/mackay/itila/ ... >> The printed version is somewhat expensive, but according to the >> following analysis it's a better barg

Re: Decimal ROUND_HALF_EVEN Default

2006-01-16 Thread Tim Peters
[3c273] > I'm just curious as to why the default rounding in the decimal module is > ROUND_HALF_EVEN instead of ROUND_HALF_UP. Because it's the best (numerically "fairest") rounding method for most people most of the time. > All of the decimal arithmetic I do is rounded half up and I can't think

Re: Decimal ROUND_HALF_EVEN Default

2006-01-17 Thread Tim Peters
[LordLaraby] > If 'bankers rounding' is HALF_ROUND_EVEN, what is HALF_ROUND_UP? Not banker's rounding ;-). Same answer if you had said ROUND_HALF_UP instead (which I assume you intended) -- most of these don't have cute names. > I confess to never having heard the terms. ROUND_HALF_UP etc are

Re: OT: excellent book on information theory

2006-01-18 Thread Tim Peters
[Paul Rubin] >> I wouldn't have figured out that a "car park" was a parking lot. I >> might have thought it was a park where you go to look at scenery from >> inside your car. Sort of a cross between a normal park and a drive-in >> movie. [Grant Edwards[ > ;) > > That's a joke, right? Probably

Re: Decimal vs float

2006-01-19 Thread Tim Peters
[Kay Schluehr] >> This is interesting. If we define >> >> def f(): >>print str(1.1) >> >> and disassemble the function, we get: >> > dis.dis(f) > 2 0 LOAD_GLOBAL 0 (str) > 3 LOAD_CONST 1 (1.1001) # huh? [Fredrik Lundh] > huh h

Re: Strange python behavior with modules on an emt64 box

2006-01-20 Thread Tim Peters
[Joshua Luben] > I thought I would post this here first before seeking more experienced ears > for this particular strangness. > > I have Python 2.4.2 installed from source on a dual processor dell server. > These are x86_64 processors (verified by /bin/arch) (aka emt64 extensions). > > uname -a gi

Re: Is there a maximum length of a regular expression in python?

2006-01-20 Thread Tim Peters
[Bryan Olson] >> Does no one care about an internal error in the regular expression >> engine? [Steve Holden] > Not one that requires parsing a 100 kilobyte re that should be replaced > by something more sensible, no. I care: this is a case of not detecting information loss due to unchecked down

Re: Can a simple a==b 'hang' in and endless loop?

2006-01-20 Thread Tim Peters
[Claudio Grondi] >> Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)] on win32 - IDLE 1.1.2 >> >>> a=[] >> >>> a.append(a) >> >>> b=[] >> >>> b.append(b) >> >>> a==b >> >> Traceback (most recent call last): >>File "", line 1, in -toplevel- >> a==b >> RuntimeError:

Re: Decimal vs float

2006-01-21 Thread Tim Peters
[Kay Schluehr] > I concur and I wonder why CAS like e.g. Maple that represent floating > point numbers using two integers [1] are neither awkward to use nor > inefficient. My guess is that it's because you never timed the difference in Maple -- or, perhaps, that you did, but misinterpreted the res

Re: hash() yields different results for different platforms

2006-07-12 Thread Tim Peters
[Grant Edwards] >> ... >> The low 32 bits match, so perhaps you should just use that >> portion of the returned hash? >> >> >>> hex(12416037344) >> '0x2E40DB1E0L' >> >>> hex(-468864544 & 0x) >> '0xE40DB1E0L' >> >> >>> hex(12416037344 & 0x) >> '0xE40DB1E0L' >> >>> hex

Re: random shuffles

2006-07-21 Thread Tim Peters
[ Boris Borcic] > x.sort(cmp = lambda x,y : cmp(random.random(),0.5)) > > pick a random shuffle of x with uniform distribution ? Say len(x) == N. With Python's current sort, the conjecture is true if and only if N <= 2. > Intuitively, assuming list.sort() does a minimal number of comparisons to

Re: Initializing the number of slots in a dictionary

2006-08-06 Thread Tim Peters
... [Jon Smirl] > I know in advance how many items will be added to the dictionary. Most > dictionary implementations I have previously worked with are more > efficient if they know ahead of time how big to make their tables. Richard Jones spent considerable time investigating whether "pre-sizing

Re: threading.Event usage causing intermitent exception

2006-08-08 Thread Tim Peters
[EMAIL PROTECTED] > Admittedly this problem causes no actual functional issues aside from > an occasional error message when the program exits. The error is: > > Unhandled exception in thread started by > Error in sys.excepthook: > Original exception was: > > Yes all that info is blank. That's ty

Re: datetime to timestamp

2006-08-11 Thread Tim Peters
[Simen Haugen] >>> How can I convert a python datetime to a timestamp? It's easy to convert >>> a timestamp to datetime (datetime.datetime.fromtimestamp(), but the >>> other way around...?) [John Machin] >> Is the timetuple() method what you want? >> >> #>>> import datetime >> #>>> n = datetime.da

Re: Inconsistency producing constant for float "infinity"

2006-08-11 Thread Tim Peters
[Peter Hansen] >> I'm investigating a puzzling problem involving an attempt to >> generate a constant containing an (IEEE 754) "infinity" value. (I >> understand that special float values are a "platform-dependent >> accident" etc...) [also Peter] > ... > My guess about marshal was correct. Yup.

Re: Inconsistency producing constant for float "infinity"

2006-08-12 Thread Tim Peters
[Tim Peters] >... >> It has a much better chance of working from .pyc in Python 2.5. >> Michael Hudson put considerable effort into figuring out whether the >> platform uses a recognizable IEEE double storage format, and, if so, >> marshal and pickle take di

Re: _PyLong_FromByteArray

2006-08-12 Thread Tim Peters
[Dan Christensen] > My student and I are writing a C extension that produces a large > integer in binary which we'd like to convert to a python long. The > number of bits can be a lot more than 32 or even 64. My student found > the function _PyLong_FromByteArray in longobject.h which is exactly >

Re: Python to use a non open source bug tracker?

2006-10-04 Thread Tim Peters
[Ben Finney] >> I don't see why you're being so obtuse [Terry Reedy] > I think name calling is out of line here. Name calling is always out of line on comp.lang.python. Unless it's done by Guido. Then it's OK. Anyone else, just remind them that even Hitler had better manners. That always calm

Re: weakSet

2006-10-05 Thread Tim Peters
[EMAIL PROTECTED] > Has anyone ever think about a set wich references its elements weakly ? Yes, and there are excruciating subtleties. I only implemented as much of one as ZODB needed at the time: # A simple implementation of weak sets, supplying just enough of Python's # sets.Set interface for

Re: Question about turning off garbage collection

2006-10-05 Thread Tim Peters
[David Hirschfield] > Question from a post to pygtk list...but it probably would be better > answered here: > > I encountered a nasty problem with an external module conflicting with > my python threads recently, and right now the only fix appears to be to > turn off garbage collection while the cr

Re: Python to use a non open source bug tracker?

2006-10-07 Thread Tim Peters
[Giovanni Bajo] > I understand your concerns, but I have to remember you that most bug reports > submitted by users go totally ignored for several years, or, better, forever. > I > do not have a correct statistic for this, Indeed you do not. > but I'm confident that at least 80% of the RFE or pa

Re: Python license question

2006-10-08 Thread Tim Peters
[Martitza] |> Hi. I work for a small company (actually in process of forming) > interested in embedding or extending python as part of our commercial > non-open-source product. We have legal counsel, but are interested in > the spirit as well as the letter of the law. Not much seems to have > be

Re: Python license question

2006-10-08 Thread Tim Peters
[Martitza] > Mr. Peters: Na, my father's dead -- you can call me Uncle Timmy ;-) > Thank you for so kindly taking the time to resolve my misunderstandings > and to elaborate on the intent of the PSF. > > In particular, thank you for explaining in plain language how the > licenses stack. I'm sure

Re: hundreds of seconds?

2006-10-11 Thread Tim Peters
[EMAIL PROTECTED] > ... > G5-fiwihex:~ eur$ python > Python 2.3.5 (#1, Mar 20 2005, 20:38:20) > [GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > >>> import time > >>> time.time() > 1160580871.258379 > >>> > > M

Re: File read-write mode: problem appending after reading

2006-10-13 Thread Tim Peters
[Frederic Rentsch] >Working with read and write operations on a file I stumbled on a > complication when writes fail following a read to the end. > > >>> f = file ('T:/z', 'r+b') > >>> f.write ('abcdefg') > >>> f.tell () > 30L > >>> f.seek (0) > >>> f.read () > 'abcdefg' > >>> f.flush ()

Re: File read-write mode: problem appending after reading

2006-10-14 Thread Tim Peters
[Frederic Rentsch] > Thanks a lot for your input. I seemed to notice that everything > works fine without setting the cursor as long as it stops before the end > of the file. Is that also a coincidence that may not work? "if you want to read following a write, or write following a read, on

Re: Dealing with multiple sets

2006-10-25 Thread Tim Peters
[John Henry] > If I have a bunch of sets: > > a = set((1, 2, 3)) > b = set((2, 3)) > c = set((1, 3)) > > > What's the cleanest way to say: > > 1) Give me a list of the items that are in all of the sets? (3 in the > above example) list(a & b & c) > 2) Give me a list of the items that are not

Re: ZODB: single database, multiple connections

2006-10-30 Thread Tim Peters
[Petra Chong] > I am using Python 2.3 and ZODB (without the rest of Zope) with the > following pattern: > > * One process which writes stuff to a ZODB instance (call it test.db) > * Another process which reads stuff from the above ZODB instance > test.db > > What I find is that when the first proce

Re: Is there a commas-in-between idiom?

2006-11-05 Thread Tim Peters
]Ernesto García García] > it's very common that I have a list and I want to print it with commas > in between. How do I do this in an easy manner, whithout having the > annoying comma in the end? > > > > list = [1,2,3,4,5,6] > > # the easy way > for element in list: >print element, ',', > > pr

Re: An oddity in list comparison and element assignment

2006-06-01 Thread Tim Peters
[EMAIL PROTECTED] > ... > As I see it, reference copying is a very useful performance and memory > optimization. But I don't think it should undermine the validity of > assert(a==b) as a predictor of invariance under identical operations. So, as Alex said last time, Try concisely expressing

Re: Large Dictionaries

2006-06-05 Thread Tim Peters
[Scott David Daniels] >> For example, time timsort (Python's internal sort) on pre-sorted >> data; you'll find it is handled faster than random data. O(N) vs O(N log N), in fact. [Lawrence D'Oliveiro] > But isn't that how a reasonable sorting algorithm should behave? Less > work to do if the data

Re: Large Dictionaries

2006-06-05 Thread Tim Peters
[Jim Segrave] > Actually, presorted lists are not a bad case for heapsort - it's quite > immune to any existing order or lack thereof, Write a heapsort and time it. It's not a difference in O() behavior, but more memory movement is required for a sorted list because transforming the list into a m

Re: Large Dictionaries

2006-06-08 Thread Tim Peters
[Tim Peters] >> ... >> O(N log N) sorting algorithms helped by pre-existing order are >> uncommon, unless they do extra work to detect and exploit >> pre-existing order. [Lawrence D'Oliveiro] > Shellsort works well with nearly-sorted data. It's basically a

Re: math.pow(x,y)

2006-06-11 Thread Tim Peters
[Wojciech Muła] >> You have to use operator **, i.e. 34564323**456356 Or the builtin pow() instead of math.pow(). [Gary Herron] > That's not very practical. That computation will produce a value with > more than 3.4 million digits. Yes. > (That is, log10(34564323)*456356 = 3440298.) Python will

Re: Numerics, NaNs, IEEE 754 and C99

2006-06-15 Thread Tim Peters
[Nick Maclaren] Firstly, a FAR more common assumption is that integers wrap in twos' complement - Python does not do that. [Grant Edwards] >>> It used to [Fredrik Lundh] >> for integers ? what version was that ? [Grant] > Am I remebering incorrectly? Mostly but not entirely. > Didn'

Re: PyObject_SetItem(..) *always* requires a Py_INCREF or not?

2006-06-17 Thread Tim Peters
[EMAIL PROTECTED] > I would think everytime you add an item to a list you must increase > reference count of that item. _Someone_ needs to. When the function called to add the item does the incref itself, then it would be wrong for the caller to also incref the item. > http://docs.python.org/api

Re: need helping tracking down weird bug in cPickle

2006-06-20 Thread Tim Peters
[Carl J. Van Arsdall] > Hey everyone, cPickle is raising an ImportError that I just don't quite > understand. When that happens, the overwhelmingly most likely cause is that the set of modules on your PYTHONPATH has changed since the pickle was first created, in ways such that a module _referenced

Re: Iteration over recursion?

2006-06-20 Thread Tim Peters
[MTD] > I've been messing about for fun creating a trial division factorizing > function and I'm naturally interested in optimising it as much as > possible. > > I've been told that iteration in python is generally more > time-efficient than recursion. Is that true? Since you heard it from me to b

Re: Python SHA-1 as a method for unique file identification ? [help!]

2006-06-21 Thread Tim Peters
[EP <[EMAIL PROTECTED]>] > This inquiry may either turn out to be about the suitability of the > SHA-1 (160 bit digest) for file identification, the sha function in > Python ... or about some error in my script It's your script. Always open binary files in binary mode. It's a disaster on Windows

Re: Iteration over recursion?

2006-06-21 Thread Tim Peters
[Kay Schluehr] > You might use a separate prime generator to produce prime factors. The > factorize algorithm becomes quite simple and configurable by prime > generators. Alas, yours was _so_ simple that it always takes time proportional to the largest prime factor of n (which may be n) instead of

Re: random.jumpahead: How to jump ahead exactly N steps?

2006-06-21 Thread Tim Peters
[Matthew Wilson] > The random.jumpahead documentation says this: > > Changed in version 2.3: Instead of jumping to a specific state, n steps > ahead, jumpahead(n) jumps to another state likely to be separated by > many steps.. > > I really want a way to get to the Nth value in a random

Re: Iteration over recursion?

2006-06-21 Thread Tim Peters
[MTD <[EMAIL PROTECTED]>] > I've been testing my recursive function against your iterative > function, and yours is generally a quite steady 50% faster on > factorizing 2**n +/- 1 for 0 < n < 60. If you're still not skipping multiples of 3, that should account for most of it. > I think that, for

Re: Is Queue.Queue.queue.clear() thread-safe?

2006-06-22 Thread Tim Peters
[Russell Warren] > I'm guessing no, since it skips down through any Lock semantics, Good guess :-) It's also unsafe because some internal conditions must be notified whenever the queue becomes empty (else you risk deadlock). > but I'm wondering what the best way to clear a Queue is then. > > Ese

Re: Is Queue.Queue.queue.clear() thread-safe?

2006-06-22 Thread Tim Peters
[Russell Warren] >>> I'm guessing no, since it skips down through any Lock semantics, [Tim Peters] >> Good guess :-) It's also unsafe because some internal conditions must >> be notified whenever the queue becomes empty (else you risk deadlock). [Fredrik Lundh] &g

Re: Questions on Threading

2006-06-26 Thread Tim Peters
[j.c.sackett] > I'm using the threading module to accomplish some distributed processing on > a project, and have a basic (I hope) question that I can't find an answer to > elsewhere. > > I've noted that there's a lot of documentation saying that there is no > external way to stop a thread, True.

Re: how to stop python...

2006-07-02 Thread Tim Peters
[bruce] > perl has the concept of "die". does python have anything similar. how can a > python app be stopped? > > the docs refer to a sys.stop. Python docs? Doubt it ;-) > but i can't find anything else... am i missing something... >>> import sys >>> print sys.exit.__doc__ exit([status]) Exit

Re: Valgrind memory-checker reports memory problems in Python

2006-07-04 Thread Tim Peters
[Nathan Bates] > Are the Python developers running Python under Valgrind? Please read Misc/README.valgrind (in your Python distribution). -- http://mail.python.org/mailman/listinfo/python-list

Re: pickling and endianess

2006-08-24 Thread Tim Peters
[Chandrashekhar kaushik] > Can an object pickled and saved on a little-endian machine be unpickled > on a big-endian machine ? Yes. The pickle format is platform-independent (native endianness doesn't matter, and neither do the native sizes of C's various integer types). > Does python handle thi

Re: random writing access to a file in Python

2006-08-25 Thread Tim Peters
[Claudio Grondi] > I have a 250 Gbyte file (occupies the whole hard drive space) Then where is Python stored ;-)? > and want to change only eight bytes in this file at a given offset of appr. > 200 > Gbyte (all other data in that file should remain unchanged). > > How can I do that in Python? S

Re: time.clock() going backwards??

2006-08-25 Thread Tim Peters
a floating point value which was "less than" the >> value returned by the previous invokation. The computer was a pretty fast >> one (P4 3Ghz I think, running Windows XP), and this happened only between >> very close invokations of time.clock(). [Terry Reed] > I se

Re: Misleading error message when opening a file (on Windows XP SP 2)

2006-08-28 Thread Tim Peters
[Claudio Grondi] > Here an example of what I mean > (Python 2.4.2, IDLE 1.1.2, Windows XP SP2, NTFS file system, 80 GByte > large file): > > >>> f = file('veryBigFile.dat','r') > >>> f = file('veryBigFile.dat','r+') > > Traceback (most recent call last): >File "", line 1, in -toplevel- >

Re: naive misuse? (of PyThreadState_SetAsyncExc)

2006-08-28 Thread Tim Peters
[EMAIL PROTECTED] >> The documentation for PyThreadState_SetAsyncExc says "To prevent naive >> misuse, you must write your own C extension to call this". Anyone care >> to list a few examples of such naive misuse? [and again] > No? I'll take that then as proof that it's impossible to misuse the >

Re: A Sort Optimization Technique: decorate-sort-dedecorate

2006-08-29 Thread Tim Peters
[Joachim Durchholz] >>> Wikipedia says it's going from 2NlogN to N. If a sort is massively >>> dominated by the comparison, that could give a speedup of up to 100% >>> (approximately - dropping the logN factor is almost irrelevant, what >>> counts is losing that factor of 2). [Gabriel Genellina] >

Re: A Sort Optimization Technique: decorate-sort-dedecorate

2006-08-29 Thread Tim Peters
7;re interested in. >>> >>> If it's asymptotic behavior, then the O(logN) factor is a difference. >>> >>> If it's practical speed, a constant factor of 2 is far more relevant >>> than any O(logN) factor. [Tim Peters] >> Nope. Even if you

Re: A Sort Optimization Technique: decorate-sort-dedecorate

2006-08-29 Thread Tim Peters
[/T] >> OTOH, current versions of Python (and Perl) [/F] > just curious, but all this use of (& Perl) mean that the Perl folks have > implemented timsort ? A remarkable case of independent harmonic convergence: http://mail.python.org/pipermail/python-dev/2002-July/026946.html Come to think

Re: GC and security

2006-08-30 Thread Tim Peters
[Aahz] >> Assuming you're talking about CPython, strings don't really participate >> in garbage collection. Keep in mind that the primary mechanism for >> reaping memory is reference counting, and generally as soon as the >> refcount for an object goes to zero, it gets deleted from memory. [Les S

Re: How to get the "longest possible" match with Python's RE module?

2006-09-11 Thread Tim Peters
[Licheng Fang] > ... > I want to know if there is some way to make Python RE behave like grep > does, Not in general, no. The matching strategies couldn't be more different, and that's both deep and intentional. See Friedl's book for details: http://regex.info/ > or do I have to change to

Re: How to get the "longest possible" match with Python's RE module?

2006-09-11 Thread Tim Peters
[Licheng Fang[ > ... > In fact, what I'm doing is handle a lot of regular expressions. I > wanted to build VERY LONG regexps part by part and put them all into a > file for easy modification and maintenance. The idea is like this: > > (*INT) = \d+ > (*DECIMAL) = (*INT)\.(*INT) > (*FACTION) = (*DECI

Re: How to get the "longest possible" match with Python's RE module?

2006-09-12 Thread Tim Peters
[Licheng Fang] >> Oh, please do have a look at the second link I've posted. There's a >> table comparing the regexp engines. The engines you've tested probably >> all use an NFA implementation. [Bryan Olson] > Unfortunately, the stuff about NFA's is wrong. Friedl's awful > book Strongly disagree:

Re: How to get the "longest possible" match with Python's RE module?

2006-09-12 Thread Tim Peters
[Licheng Fang] >> Basically, the problem is this: >> >> >>> p = re.compile("do|dolittle") >> >>> p.match("dolittle").group() >> 'do' ... >> The Python regular expression engine doesn't exaust all the >> possibilities, but in my application I hope to get the longest possible >> match, starting fro

Re: How to get the "longest possible" match with Python's RE module?

2006-09-12 Thread Tim Peters
[Bryan Olson] >>> Unfortunately, the stuff about NFA's is wrong. Friedl's awful >>> book [Tim Peters] >> Strongly disagree: [...] [Bryan] > I know I'm disagreeing with a lot of smart people in panning > the book. That's allowed :-) >>&

Re: min() & max() vs sorted()

2006-09-14 Thread Tim Peters
[MRAB] > Some time after reading about Python 2.5 and how the built-in functions > 'min' and 'max' will be getting a new 'key' argument, I wondered how > they would treat those cases where the keys were the same, for example: > > L = ["four", "five"] > print min(L, key = len), max(L, key = len) > >

Re: how do you convert and array of doubles into floats?

2006-09-15 Thread Tim Peters
[Marc 'BlackJack' Rintsch] >> What about: >> >> b = array.array('f', a) [Diez B. Roggisch] > AFAIK d and f are synonym for arrays, as python doesn't distinguish > between these two on a type-level. And double it is in the end. While Python has no type of its own corresponding to the native C `flo

Re: min() & max() vs sorted()

2006-09-15 Thread Tim Peters
t;> >>> L = ["four", "five"] >>> print min(L, key = len), max(L, key = len) >>> >>> The result is: >>> >>> ('four', 'four') [Tim Peters] >> min() and max() both work left-to-right, and return t

Re: How to get the "longest possible" match with Python's RE module?

2006-09-16 Thread Tim Peters
[Tim Peters] >> [...] The most valuable general technique [Friedl] (eventually ;-) >> explained he called "unrolling", and consists of writing a regexp in >> the form: >> >>normal* (?: special normal* )* >> >> where the sets of character

Re: Hardlinks on NTFS

2006-09-17 Thread Tim Peters
[Wildemar Wildenburger] >> I'm thinking of letting my program create hardlinks (or symlinks). I >> know python allows doing this for ext, reiser and the like, but >> apparently not for ntfs systems. >> Is there any package out there that lets me create links in a platform >> independent way? [Calv

Re: Installing 2.5 with 2.4?

2006-09-20 Thread Tim Peters
[Duncan Booth] >> Windows is only smart enough to avoid duplicate entries if you tell it >> to do that. e.g. >> >> PATH c:\python25;c:\python25\scripts;%PATH:c:\python25;c:\python25\scripts;=% >> >> will add the two Python 2.5 folders to the head of the path without >> duplicating them. [John Mach

Re: Is this a bug? Python intermittently stops dead for seconds

2006-10-01 Thread Tim Peters
[charlie strauss] > Below is a simple program that will cause python to intermittently > stop executing for a few seconds. it's 100% reproducible on my machine. Any program that creates a great many long-lived container objects will behave similarly during the creation phase. Others have explain

Re: Is this a bug? Python intermittently stops dead for seconds

2006-10-01 Thread Tim Peters
[charlie strauss] >>> Below is a simple program that will cause python to intermittently >>> stop executing for a few seconds. it's 100% reproducible on my >>> machine. [Giovanni Bajo] >> Confirmed with Python 2.4.2 on Windows. [Jorgen Grahn] > And Python 2.3.5 on Linux, amd64. In fact, it caus

Re: Is this a bug? Python intermittently stops dead for seconds

2006-10-01 Thread Tim Peters
[Steve Holden, "pins the blame" for pauses on periodic cyclic gc] > ... > So basically what you have here is a pathological example of why it's > sometimes wise to disable garbage collection. Tim, did I miss anything? Nope! -- http://mail.python.org/mailman/listinfo/python-list

Re: Is this a bug? Python intermittently stops dead for seconds

2006-10-01 Thread Tim Peters
[charlie strauss] > I want to clarify that, on my computer, the first instance of the gap occurs > way > before the memory if filled. (at about 20% of physical ram). Additionally the > process monitor shows no page faults. Python has no idea of how much RAM you have, or even of how much RAM it's

Re: Is this a bug? Python intermittently stops dead for seconds

2006-10-01 Thread Tim Peters
[charlie strauss] > Steve, digging into the gc docs a bit more, I think the behaviour I am seeing > is still > not expected. Namely, the program I offered has no obvious place where > objects > are deallocated. The way GC is supposed to work is thate there are three > levels of > objects > > l

Re: Is this a bug? Python intermittently stops dead for seconds

2006-10-01 Thread Tim Peters
[Charlie Strauss] >>> level0: newly created objects >>> level1: objects that survived 1 round of garbage collection >>> level2: objects that survivied 2+ rounds of gargbage collection >>> >>> Since all of my numerous objects are level2 objects, and none of >>> them are every deallocated, then I

Re: Decimal() instead of float?

2006-11-17 Thread Tim Peters
[Michael B. Trausch] >> Let's say that I want to work with the latitude 33.6907570. In Python, >> that number > can not be stored exactly without the aid of >> decimal.Decimal(). >> >> >>> 33.6907570 >> 33.6907568 >> >>> >> >> As you can see, it loses accuracy after the 6th decimal place.

Re: syntax error in sum(). Please explicate.

2006-11-18 Thread Tim Peters
[Matt Moriarity] >> try surrounding your sum argument in brackets: >> >> sum([phi(x // ps[i+1], i) for i in range(a)]) >> >> instead of: >> >> sum(phi(x // ps[i+1], i) for i in range(a)) [Michael Press] > Thank you. That makes it work. But is a wrong solution ;-) As others have suggested, it's a

Re: Python spam?

2006-11-30 Thread Tim Peters
[Aahz] >>> Anyone else getting "Python-related" spam? So far, I've seen messages >>> "from" Barry Warsaw and Skip Montanaro (although of course header >>> analysis proves they didn't send it). [Thomas Heller] >> I'm getting spam not only from Barry, but also from myself ;-) with >> forged headers

Re: merits of Lisp vs Python

2006-12-11 Thread Tim Peters
[Paddy] >> http://en.wikipedia.org/wiki/Doctest [Kaz Kylheku] > I pity the hoplelessly anti-intellectual douche-bag who inflicted this > undergraduate misfeature upon the programming language. As a blind misshapen dwarf, I get far too much pity as it is, but I appreciate your willingness to sha

Re: not a big deal or anything, but, curiously:

2006-12-12 Thread Tim Peters
[Simon Schuster] > following this tutorial, Which tutorial? > I copied and pasted: > > from string import * > > cds = """atgagtgaacgtctgagcattagctccgtatatcggcgcacaaa > tttcgggtgccgacctgacgcgcccgttaagcgataatcagtttgaacagctttaccatgcggtg > ctgcgccatcaggtggtgtttctacgcgatcaagctattacgccgcagcagca

Re: merits of Lisp vs Python

2006-12-13 Thread tim . peters
[Bill Atkins] >> (Why are people from c.l.p calling parentheses "brackets"?) [Kaz Kylheku] > Because that's what they are often called outside of the various > literate fields. For example, the English are "outside of the various literate fields"? FWIW, Python documentation consistently uses the

Re: a question on python dict

2006-12-20 Thread Tim Peters
[EMAIL PROTECTED] > Python dict is a hash table, isn't it? Yup. > I know that hashtable has the concept of "bucket size" and "min bucket > count" stuff, Some implementations of hash tables do. Python's does not. Python's uses what's called "open addressing" instead. > and they should be confi

Re: a question on python dict

2006-12-31 Thread Tim Peters
[Tim Peters] >> You should also note that copying a dict key or value (no matter of >> what type) consists in its entirety of copying one machine address (a >> 4- or 8-byte pointer, depending on platform). [Lawrence D'Oliveiro] > Actually, no. It also consists of updatin

Re: a question on python dict

2006-12-31 Thread Tim Peters
[Tim Peters] >>>> You should also note that copying a dict key or value (no matter of >>>> what type) consists in its entirety of copying one machine address (a >>>> 4- or 8-byte pointer, depending on platform). [Lawrence D'Oliveiro] >>> Actually,

Re: a question on python dict

2007-01-03 Thread Tim Peters
[Tim Peters] >> ... >> Taking my response out of context to begin with doesn't really change >> that I answered the question he asked ;-) [Fredrik Lundh] > welcome to comp.lang.python. > > Thanks for the welcome! It's tough to be a newbie here ;-) -- ht

Re: Q: About a programming problem with Python!

2007-01-08 Thread Tim Peters
[followups set to comp.lang.python] [Danny] > I am just getting into OOP using Python and > because of the floating point of large integer (L) > square roots all the decimal expansions are truncated. > This has created a problem because I need these > decimal expansions in my algorithm other wise

Re: Maths error

2007-01-09 Thread Tim Peters
[Rory Campbell-Lange] >>> Is using the decimal module the best way around this? (I'm >>> expecting the first sum to match the second). It seem >>> anachronistic that decimal takes strings as input, though. [Nick Maclaren] >> As Dan Bishop says, probably not. The introduction to the decimal >> mod

Re: Maths error

2007-01-09 Thread Tim Peters
[Tim Peters] ... >|> Well, just about any technical statement can be misleading if not >|> qualified to such an extent that the only people who can still >|> understand it knew it to begin with <0.8 wink>. The most dubious >|> statement here to my eyes is the i

Re: Possible memory leak?

2006-01-25 Thread Tim Peters
[Fredrik Lundh] >> ... >> for the OP's problem, a PIL-based solution would probably be ~100 >> times faster than the array solution, but that's another story. [Tuvas] > What do you mean by a PIL based solution? The reason I need to get the > data into the string list is so I can pump it into PIL t

Re: writing large files quickly

2006-01-28 Thread Tim Peters
[Jens Theisen] > ... > Actually I'm not sure what this optimisation should give you anyway. The > only circumstance under which files with only zeroes are meaningful is > testing, and that's exactly when you don't want that optimisation. In most cases, a guarantee that reading "uninitialized" file

Re: os.walk() dirs and files

2006-02-08 Thread Tim Peters
[rtilley] > When working with file and dir info recursively on Windows XP. I'm going > about it like this: > > for root, dirs, files in os.walk(path): > for f in files: > ADD F to dictionary > for d in dirs: > ADD D to dictionary > > Is it possible to do something such a

Re: how do you pronounce 'tuple'?

2006-02-14 Thread Tim Peters
[EMAIL PROTECTED] > ... > I work with Guido now and I'm conflicted. I'm still conditioned to say > tuhple. Whenever he says toople, I just get a smile on my face. I > think most of the PythonLabs guys pronounce it toople. "tuhple" is a girly-man affectation. That's why Guido and I both say the

Re: processing limitation in Python

2006-02-14 Thread Tim Peters
[EMAIL PROTECTED] > If I un-comment any line in this program below the line where I > commented " all OK up to this point " This program locks up my > computer. > > Windows task manager will show "Not Responding" for Python in the > Applications tab and in the Performance tabe the CPU usage will be

Re: Queue.Queue()

2006-02-17 Thread Tim Peters
[john peter] > what happens behind the scenes when i create a Queue.Queue() without > specifying a maxsize? does a block of space gets allocated initially then > dynamically "expanded" as needed? Yes. > if so, what is the default size of the initial space? It's initially empty. > is it always

Re: Python Challenge ahead [NEW] for riddle lovers

2005-05-03 Thread Tim Peters
[Chris McAloney] > Okay, so I've been working on level seven for a LONG time now. Hmm. I've been staring at that one 18 hours a day since last Friday, and still don't have the foggiest idea. I've counted boxes, counted pixels, broken it apart and rearranged it like a jigsaw puzzle, ran "strings"

Re: Python Challenge ahead [NEW] for riddle lovers

2005-05-03 Thread Tim Peters
[Tiziano Bettio] > PLEASE HELP... > > What the hell do i have to pronounce in puzzle 5 > > Some useful hints would be awesome That's a funny one: I didn't understand the "pronounce it" hint until long after I solved that one. Then again, Guido & I implemented PEP 307, so I knew what to do th

Re: Python Challenge ahead [NEW] for riddle lovers

2005-05-03 Thread Tim Peters
[Tim Peters, whines about level 7] [Dan Christensen, gives a huge hint] The first time I looked at it, I thought "hmm, I should use PIL for this". I kept thinking that too -- but for some reason wanted to see if there was a clear way to do it without something that "fancy"

Re: Inverse confusion about floating point precision

2005-05-09 Thread Tim Peters
[Skip Montanaro] > I understand why the repr() of float("95.895") is "95.8949996". > What I don't understand is why if I multiply the best approximation to > 95.895 that the machine has by 1 I magically seem to get the lost > precision back. To wit: > >% python >Python 2.3.4 (#

Re: Inverse confusion about floating point precision

2005-05-09 Thread Tim Peters
[Dan] >Dan> The floating-point representation of 95.895 is exactly >Dan> 6748010722917089 * 2**-46. [Skip Montanaro] > I seem to recall seeing some way to extract/calculate fp representation from > Python but can't find it now. I didn't see anything obvious in the > distribution. For Da

<    1   2   3   4   >