Re: Rollover/wraparound time of time.clock() under win32?

2005-09-28 Thread Tim Peters
[Russell Warren, playing w/ time.clock() on Windows] > ... > Based on this code and some quick math it confirms that not only will > the rollover be a looong way out, but that there will not be any loss > in precision until ~ 30 years down the road. Checking my math: > > (float(10**16 + 1) - floa

Re: Absolultely confused...

2005-10-06 Thread Tim Peters
[Jeremy Moles] > ... > I may be missing something critical here, but I don't exactly grok what > you're saying; how is it even possible to have two instances of > PyType_vector3d? It is (like all the examples show and all the extension > modules I've done in the past) a static structure declared an

Re: Merging sorted lists/iterators/generators into one stream of values...

2005-10-08 Thread Tim Peters
[Alex Martelli] >>> try it (and read the Timbot's article included in Python's sources, and the >>> sources themselves)... [Kay Schluehr] >> Just a reading advise. The translated PyPy source >> pypy/objectspace/listsort.py might be more accessible than the >> corresponding C code. [cfbolz] > inde

Re: Hidden string formatting bug

2005-10-13 Thread Tim Peters
[Echo] > I have been trying to figure out the problem with this string formatting: [monstrous statement snipped] > when it executes, I get this error: "inv argument required". That shoud be "int", not "inv". > I have checked and rechecked both the string and the tuple. I cant figure > out what

Re: Queue question

2005-10-17 Thread Tim Peters
[Alex Martelli] > ... > not_empty and not_full are not methods but rather instances of the > threading.Condition class, which gets waited on and notified > appropriately. I'm not entirely sure exactly WHAT one is supposed to do > with the Condition instances in question (I'm sure there is some des

Re: wierd threading behavior

2005-10-18 Thread Tim Peters
[Qun Cao] >> import thread >> def main(): >> thread.start_new(test.()) >> >> def test(): >> print 'hello' >> >> main() >> " >> this program doesn't print out 'hello' as it is supposed to do. >> while if I change main() [Neil Hodgson] >The program has exited before the thread has manage

Re: Would there be support for a more general cmp/__cmp__

2005-10-20 Thread Tim Peters
[Toby Dickenson] > ... > ZODB's BTrees work in a similar way but use the regular python comparison > function, and the lack of a guarantee of a total ordering can be a liability. > Described here in 2002, but I think same is true today: > http://mail.zope.org/pipermail/zodb-dev/2002-February/002304

Re: migrate from ZODB 3.3.1 --- to where, and how?

2005-10-25 Thread Tim Peters
[Harald Armin Massa] > I am using ZODB "standalone" in version 3.3.1 within some application. > > Now I learn that the 3.3.x branch of ZODB is "retired". No problem so > far, everything is running fine. > > BUT... "retired" gives me the hint that nothing GREAT will be done to > this branch anymore

Re: more than 100 capturing groups in a regex

2005-10-27 Thread Tim Peters
[DH] >> It's a conflict between python's syntax for regex back references >> and octal number literals. Probably wasn't noticed until way too >> ate, and now it will never change. [EMAIL PROTECTED] > I suspect it comes from Perl, since Python's regular expression engine tries > pretty hard to be

Re: Is bytecode machine (in)dependent?

2005-10-28 Thread Tim Peters
[Robert McLay] > I'm trying to understand bytecodes generated on different machines. > I understand that the bytecodes can change between version. But since > I'm told that .pyc files are version dependent but not machine > dependent, I'm wondering why the bytecodes are machine dependent. They ar

Re: Recursive generators and backtracking search

2005-10-31 Thread Tim Peters
[Talin] > I've been using generators to implement backtracking search for a while > now. Unfortunately, my code is large and complex enough (doing > unification on math expressions) that its hard to post a simple > example. So I decided to look for a simpler problem that could be used > to demonstr

Re: python gc performance in large apps

2005-11-06 Thread Tim Peters
[Robby Dermody] > ... > -len(gc.get_objects()) will show linearly increasing counts over time > with the director (that match the curve of the director's memory usage > exactly), but with the harvester, the object count doesn't increase over > time (although memory usage does). This might mean that

Re: regexp non-greedy matching bug?

2005-12-03 Thread Tim Peters
[John Hazen] > I want to match one or two instances of a pattern in a string. > > According to the docs for the 're' module > ( http://python.org/doc/current/lib/re-syntax.html ) the '?' qualifier > is greedy by default, and adding a '?' after a qualifier makes it > non-greedy. >> The "*", "+", an

Re: hash()

2005-12-05 Thread Tim Peters
[John Marshall] > For strings of > 1 character, what are the chances > that hash(st) and hash(st[::-1]) would return the > same value? First, if `st` is a string, `st[::-1]` is a list. Do you really mean to compare string hashes with list hashes here? I'm going to assume not. Second, what are y

Re: hash()

2005-12-05 Thread Tim Peters
[John Marshall] >>> For strings of > 1 character, what are the chances >>> that hash(st) and hash(st[::-1]) would return the >>> same value? [Tim Peters] >> First, if `st` is a string, `st[::-1]` is a list. Do you really mean >> to compare string h

Re: UNIX timestamp from a datetime class

2005-12-06 Thread Tim Peters
[John Reese] > >>> import time, calendar, datetime > >>> n= 1133893540.874922 > >>> datetime.datetime.fromtimestamp(n) > datetime.datetime(2005, 12, 6, 10, 25, 40, 874922) > >>> lt= _ > >>> datetime.datetime.utcfromtimestamp(n) > datetime.datetime(2005, 12, 6, 18, 25, 40, 874922) > >>> gmt= _ > > S

Re: binascii.crc32 results not matching

2005-12-09 Thread Tim Peters
[Larry Bates] > I'm trying to get the results of binascii.crc32 > to match the results of another utility that produces > 32 bit unsigned CRCs. binascii.crc32 returns > results in the range of -2**31-1 and 2**21-1. Has > anyone ever worked out any "bit twiddling" code to > get a proper unsigned 32

Re: newby question: Splitting a string - separator

2005-12-09 Thread Tim Peters
[James Stroud] >> The one I like best goes like this: >> >> py> data = "Guido van Rossum Tim Peters Thomas Liesner" >> py> names = [n for n in data.split() if n] >> py> names >> ['Guido', 'van', 'Rossum', &#x

Re: binascii.crc32 results not matching

2005-12-10 Thread Tim Peters
[Raymond L. Buvel] > Check out the unit test in the following. > > http://sourceforge.net/projects/crcmod/ Cool! > I went to a lot of trouble to get the results to match the results of > binascii.crc32. As you will see, there are a couple of extra operations > even after you get the polynomial a

Re: thread/queue bug

2005-01-02 Thread Tim Peters
[EMAIL PROTECTED] Note that python-bugs-list is a moderated list for use only by automated reports generated from SourceForge. I'm redirecting the reply to [EMAIL PROTECTED] > I have a very strange bug. A thread in a .pyc stops dead. > > This program has many threads and queues and has worked

Re: Restore a unified diff

2005-01-04 Thread Tim Peters
[Nick Allen] > After using ndiff from difflib, the function restore > would return the sequence that generated the delta. It can actually reproduce either sequence from which the delta was generated. But this is really trivial: ndiff was intended to produce diff output for humans to read, and in

Re: Restore a unified diff

2005-01-05 Thread Tim Peters
[Nick Allen] >>> Unfortunately, restore does not do the same for unified_diff. I do >>> not see any similar function that is intended for unified_diff. >>> Does anyone know how to "restore" from a unified diff generated >>> delta? [Tim Peters] >&g

Re: sorting on keys in a list of dicts

2005-01-07 Thread Tim Peters
[Nick Coghlan] ... > Python 2.3 has a stable sort, and Python 2.4 brought the guarantee that it > shall > remain that way. I'm not sure about Python 2.2 and earlier. No list.sort() implementation before 2.3 was stable. It was confusing, though, because the samplesort/binary_insertion_sort hybrid

Re: Returning same type as self for arithmetic in subclasses

2005-01-07 Thread Tim Peters
[Max M] > """ > I subclass datetime and timedelta > > >>> dt = myDatetime(1970,1,1) > >>> type(dt) > > > >>> td = myTimedelta(hours=1) > >>> type(td) > > > But when I do arithmetic with these classes, they return datetime and > timedelta, ... > >>> new_time = dt + td > >>> new_time > datetime.

Re: time module precision

2005-01-08 Thread Tim Peters
[Jane Austine] > What is the precision (and accuracy) of time module on a Windows XP > machine? There are many functions in the time module. You shouldn't assume that any two have similar behavior (because, in fact, they may not). > threading module depends on time module so it's precision(and >

Re: time module precision

2005-01-09 Thread Tim Peters
[Tim Peters] >> Python's time.sleep() calls the Win32 API Sleep() function on >> Windows. All behavior is inherited from the latter. See MS's docs: >> >> >> <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/sleep.asp> [EM

Re: Writing huge Sets() to disk

2005-01-10 Thread Tim Peters
[Martin MOKREJÅ] > just imagine, you want to compare how many words are in English, German, > Czech, Polish disctionary. You collect words from every language and record > them in dict or Set, as you wish. Call the set of all English words E; G, C, and P similarly. > Once you have those Set's o

Re: Writing huge Sets() to disk

2005-01-10 Thread Tim Peters
[Martin MOKREJÅ] > ... > > I gave up the theoretical approach. Practically, I might need up > to store maybe those 1E15 keys. We should work on our multiplication skills here . You don't have enough disk space to store 1E15 keys. If your keys were just one byte each, you would need to have 4 th

Re: Writing huve ge Sets() to disk

2005-01-10 Thread Tim Peters
[Tim Peters] >> As I mentioned before, if you store keys in sorted text files, >> you can do intersection and difference very efficiently just by using >> the Unix `comm` utiltity. [Martin MOKREJÅ] > Now I got your point. I understand the comm(1) is written in C, but it stil

Re: Securing a future for anonymous functions in Python

2005-01-10 Thread Tim Peters
... [Anna] >> BTW - I am *quite* happy with the proposal for "where:" syntax - I >> think it handles the problems I have with lambda quite handily. [Steve Holden] > Whereas I find it to be an excrescence, proving (I suppose) that one > man's meat is another person's poison, or something. I've be

Re: Writing huge Sets() to disk

2005-01-10 Thread Tim Peters
[Istvan Albert] > #- I think that you need to first understand how dictionaries work. > #- The time needed to insert a key is independent of > #- the number of values in the dictionary. [Batista, Facundo] > Are you sure? > > I think that is true while the hashes don't collide. If you have co

Re: python 2.3.4 for windows: float("NaN") throws exception

2005-01-13 Thread Tim Peters
[EMAIL PROTECTED] > my python 2.3.4 for windows refuse to execute line float("NaN"). It > says: > > >>> float("NaN") > Traceback (most recent call last): > File "", line 1, in ? > ValueError: invalid literal for float(): NaN > > The same line works as expected on Linux and Solaris with python 2.3.

Re: python 2.3.4 for windows: float("NaN") throws exception

2005-01-13 Thread Tim Peters
[EMAIL PROTECTED] > C99 and Fortran 2003 have IEEE arithmetic. Not that simple (e.g., C99 doesn't *require* it; but it has a pile of specified IEEE behaviors a conforming C99 compiler can choose to support (or not), along with a preprocessor symbol those that do so choose can #define to advertise

Re: Pickled text file causing ValueError (dos/unix issue)

2005-01-14 Thread Tim Peters
[Aki Niimura] > I started to use pickle to store the latest user settings for the tool > I wrote. It writes out a pickled text file when it terminates and it > restores the settings when it starts. ... > I guess DOS text format is creating this problem. Yes. > My question is "Is there any elegant

Re: Writing huge Sets() to disk

2005-01-14 Thread Tim Peters
[Martin MOKREJÅ] > This comm(1) approach doesn't work for me. It somehow fails to > detect common entries when the offset is too big. > > file 1: > > A > F > G > I > K > M > N > R > V > AA > AI > FG > FR > GF > GI > GR > IG > IK > IN > IV > KI > MA > NG > RA > RI > VF > AIK > FGR > FRA > GFG > GIN

Re: Why 'r' mode anyway? (was: Re: Pickled text file causing ValueError (dos/unix issue))

2005-01-14 Thread Tim Peters
[Irmen de Jong] > I've been wondering why there even is the choice between binary mode > and text mode. Why can't we just do away with the 'text mode' ? > What does it do, anyways? At least, if it does something, I'm sure > that it isn't something that can be done in Python itself if > really requi

Re: Pickled text file causing ValueError (dos/unix issue)

2005-01-14 Thread Tim Peters
[Tim Peters] >>Yes: regardless of platform, always open files used for pickles >> in binary mode. ... [John Machin] > Tim, the manual as of version 2.4 does _not_ mention the need > to use 'b' on OSes where it makes a difference, not even in the > examples at the

Re: oddities in the datetime module

2005-01-14 Thread Tim Peters
[Max M] > ... > First of, it should be possible to easily convert between the > datetime objects. Why? All the conversions people asked for when the module was being designed were implemented. > And eg. the date object doesn't have a datetime() method. Which > it could easily have. But not a *s

Re: Why 'r' mode anyway?

2005-01-14 Thread Tim Peters
[Tim Peters] >> That differences may exist is reflected in the C >> standard, and the rules for text-mode files are more restrictive >> than most people would believe. [Irmen de Jong] > Apparently. Because I know only about the Unix <-> Windows > difference (wind

Re: python mode indentation problem

2005-01-15 Thread Tim Peters
[Xah Lee] ... > © who the fuck coded the python mode in emacs? The major contributors are listed at the top of python-mode.el. > fuckhead please peruse: > © http://xahlee.org/UnixResource_dir/writ/responsible_license.html OK, I read it, but have no idea what point you're trying to make here. If

Re: interpret 4 byte as 32-bit float (IEEE-754)

2005-01-16 Thread Tim Peters
[Bengt Richter] ... > But I don't know how to build QNaNs: You can subtract infinity from infinity. While all Python behavior in the presence of NaNs, infinities, and signed zeroes is a platform-dependent accident, it you're on a box that has such things, and figure out some (accidental!) way to

Re: Py_Object* Py_BuildValue, Py_INCREF necessary?

2005-01-17 Thread Tim Peters
[Torsten Mohr] > when i write an extension module in C and return a Py_Object* > that i've built with Py_BuildValue, do i need to use Py_INCREF > on that before i return it to python from my extension module > or not? The docs for Py_BuildValue() say it returns a new reference (and it does). So t

Re: Zen of Python

2005-01-19 Thread Tim Peters
different meaning. It's not that "Flat is better than > nested" it's that "Too flat is bad and too flat is nested so be as < nested (or as flat) as you have to be and no more." Perhaps Tim > Peters is far too concise for my feeble mind Always happy to help a fellow

Re: Zen of Python

2005-01-19 Thread Tim Peters
[Paul Rubin] > Huh? [1,2,[3,4,5],[6,7]],8 is a perfectly valid Python list. You're claiming not to know any relevant difference between Python lists and Lisp lists? Heh. > And you can break out of a containing loop from a nested loop > with try/raise. Heh heh. Yes, you can. I've neve

Re: why no time() + timedelta() ?

2005-01-20 Thread Tim Peters
[josh] > Why can't timedelta arithmetic be done on time objects? Obviously, because it's not implemented . > (e.g. datetime.time(5)-datetime.timedelta(microseconds=3) > > Nonzero "days" of the timedelta could either be ignored, or > trigger an exception. And if the result is less than 0, or >= 2

Re: PyCon Preliminary Program Announced!

2005-01-20 Thread Tim Peters
[Bryan] > can anyone tell me how the talks work? there are between 9 > and 12 talks for each time slot. do all talks start at the same > time? or are there just four talks at a time and the columns show > what talks are in a given room? The web page needs better formatting. In general, there ar

Re: PyCon Preliminary Program Announced!

2005-01-21 Thread Tim Peters
[A.M. Kuchling] > Suggestions for improvement are welcome. Perhaps the Wiki version of > the schedule, at http://www.python.org/moin/PyConDC2005/Schedule, > may be better. It is, but the 2004 schedule was really what I had in mind (very readable!): http://www.python.org/pycon/dc2004/schedule

Re: Zen of Python

2005-01-21 Thread Tim Peters
[Paul Rubin] >> You snipped out the examples I gave, like [x*x for x in range(5)] >> leaving unnecessary residue in the name space. Was it not >> obvious from the beginning that that was a kludge? If it was >> obviously a kludge, was it not obvious that there would be >> reason to want to fix it

Re: Tuple size and memory allocation for embedded Python

2005-01-21 Thread Tim Peters
[Jinming Xu] >> Python seems unstable, when allocating big memory. For >> example, the following C++ code creates a tuple of tuples: >> >> PyObject* arCoord = PyTuple_New(n); >> double d = 1.5; >> for(int i=0; i> { >> PyObject* coord = PyTuple_New(2); >> PyTuple_SetItem(coord

Re: Zen of Python

2005-01-22 Thread Tim Peters
[Tim Peters] >> But at that time, Python didn't have lexical scoping, and it wasn't >> clear that it ever would. So what's the bigger wart? Making >> listcomps exactly equivalent to an easily-explained Python for-loop >> nest, or introducing a notion of lex

Re: Classical FP problem in python : Hamming problem

2005-01-23 Thread Tim Peters
[Francis Girard] > ... > In the meantime, I couldn't resist to test the new Python features about > laziness on a classical FP problem, i.e. the "Hamming" problem. ... > Nevertheless, while the Haskell version prints Hamming sequence for as long as > I can stand it, and with very little memory cons

Re: Weakref.ref callbacks and eliminating __del__ methods

2005-01-23 Thread Tim Peters
[Mike C. Fletcher] > I'm looking at rewriting parts of Twisted and TwistedSNMP to eliminate > __del__ methods (and the memory leaks they create). A worthy goal! > Looking at the docs for 2.3's weakref.ref, there's no mention of whether the > callbacks are held with a strong reference. A callback

Re: Memory Usage

2005-01-24 Thread Tim Peters
[<[EMAIL PROTECTED]>] > Would a Python process consume more memory on a PC with lots of > memory? > > For example, say I have the same Python script running on two WinXP > computers that both have Python 2.4.0. One computer has 256 MB of Ram > while the other has 2 GB of Ram. On the machine with le

Re: Weakref.ref callbacks and eliminating __del__ methods

2005-01-24 Thread Tim Peters
[Tim] >> I'll note that one fairly obvious pattern works very well for weakrefs >> and __del__ methods (mutatis mutandis): don't put the __del__ method >> in self, put it in a dead-simple object hanging *off* of self. Like >> the simple: >> >> class BTreeCloser: >> def __init__(self, btree):

Re: Classical FP problem in python : Hamming problem

2005-01-24 Thread Tim Peters
[Francis Girard] > For all the algorithms that run after their tail in an FP way, like the > Hamming problem, or the Fibonacci sequence, (but unlike Sieve of Eratosthene > -- there's a subtle difference), i.e. all those algorithms that typically > rely upon recursion to get the beginning of the gen

Re: threading.py Condition wait overflow error

2005-01-25 Thread Tim Peters
[Mark English] > Every once in a while since I moved to Python 2.4 I've been seeing the > following exception in threading.py Condition: > > File "mctest3.py", line 1598, in WaitForMessages >self.condResponses.wait(1.0) > File "C:\Program Files\Python24\lib\threading.py", line 221, in wait >

Re: python memory blow out

2005-01-26 Thread Tim Peters
[Simon Wittber] >> According to the above post: >>a) If the allocation is > 256 bytes, call the system malloc. >>b) If the allocation is < 256, use its own malloc implementation, which >> allocates memory in 256 kB chunks and never releases it. >> >> I imagine this means that large me

Re: threading.py Condition wait overflow error

2005-01-26 Thread Tim Peters
[Tim Peters] ... >> The most common cause for "impossible exceptions" > is flawed C code in an extension that fails to >> check a Python C API call for an error return. [Mark English] > Yes, I use a lot of C modules which I wrote. Then you know where to start lookin

Re: On benchmarks, heaps, priority queues

2005-01-27 Thread Tim Peters
[EMAIL PROTECTED], on ] > Yes I know in theory the insertion sort approach should be bad for > large enough values, but the weird thing is that if you mix inserts and > deletes (with enough deletes) even 1M elements is not a large enough > value. Anyway,

Re: Who should security issues be reported to?

2005-01-28 Thread Tim Peters
[EMAIL PROTECTED] > Who are the appropriate people to report security problems to > in respect of a module included with the Python distribution? > I don't feel it appropriate to be reporting it on general mailing > lists. The Python project has no non-public resources for this. Filing a bug repo

Re: pickle, cPickle, & HIGHEST_PROTOCOL

2005-01-30 Thread Tim Peters
[A.B., Khalid] > I wonder if someone can explain what is wrong here. I am pickling a > list of dictionaries (see code attached) and unpickling it back using > the HIGHEST_PROTOCOL of pickle and cPickle. ... > ... on Win98. Pickles are binary data. Therefore you should open pickle files in binary

Re: pythonic equivalent of Mathematica's FixedPoint function

2005-02-01 Thread Tim Peters
[jelle] > I now some hostility to functional programming is flaming up now and > then; still could someone suggest me a pythonic equivalent for > Mathematica's FixedPoint function? For those not familiar with > Mathematica: > > FixedPoint[f, expr] starts with expr, then applies f repeatedly until >

Re: Where are list methods documented?

2005-02-01 Thread Tim Peters
[Grant Edwards] > I'm trying to figure out how to sort a list, and I've run into > a problem that that I have tripped over constantly for years: > where are the methods of basic types documented? The methods on mutable sequence types are documented in the Library manual's section on mutable sequen

Re: Where are list methods documented?

2005-02-01 Thread Tim Peters
[Tim Peters] >> You could have found the above by, e.g., looking up "sort" in the >> Library manual's index. [Grant Edwards] > I did. I looked up sort in the library index, and it took me > to 3.3.5 Emulating container types, It doesn't for me.

Re: pickle/marshal internal format 'life expectancy'/backward compatibility

2005-02-05 Thread Tim Peters
[Philippe C. Martin] > I am looking into using the pickle format to store object/complex data > structures into a smart card as it would make the design of the embedded > application very simple. > > Yet the card might have to stay in the pocket of the customer for a few > years, during which the b

Re: Pickling and inheritance are making me hurt

2005-02-05 Thread Tim Peters
[Kirk Strauser] > I have a module that defines a Search class and a SearchResult class. Try posting a minimal self-contained code sample that fails. > I use these classes by writing other modules that subclass both of them as > needed to interface with particular search engines. > > My problem i

Re: multi threading and win9x

2005-06-20 Thread Tim Peters
[Timothy Smith] > i want to run my sql statements on a seperate thread to prevent my app > from stop responding to input (atm is says "not responding" under > windows until the sql is finished) > but i'm hesitant because i have to still support win9x and i'm not sure > how well this will play. All

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Tim Peters
[with the start of US summer comes the start of 754 ranting season] [Grant Edwards] Negative 0 isn't a NaN, it's just negative 0. [Scott David Daniels] >>> Right, but it is hard to construct in standard C. [Paul Rubin] >> Huh? It's just a hex constant. [Scott David Daniels] > Well, -0.0 d

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-22 Thread Tim Peters
[Tim Peters] ... >> Across platforms with a 754-conforming libm, the most portable way [to >> distinguish +0.0 from -0.0 in standard C] is via using atan2(!): >> >> >>> pz = 0.0 >> >>> mz = -pz >> >>> from math import atan2 >>

Re: pickle broken: can't handle NaN or Infinity under win32

2005-06-23 Thread Tim Peters
[Tim Peters'] >> Well, I try, Ivan. But lest the point be missed , 754 doesn't >> _want_ +0 and -0 to act differently in "almost any" way. The only >> good rationale I've seen for why it makes the distinction at all is in >> Kahan's paper &qu

Re: Avoiding deadlocks in concurrent programming

2005-06-23 Thread Tim Peters
[Terry Hancock] > ... > I realize you've probably already made a decision on this, but this sounds > like a classic argument for using an *object DBMS*, such as ZODB: It > certainly does support transactions, and "abstracting the data into tables" > is a non-issue as ZODB stores Python objects more

Re: Tracing down segfault

2005-06-24 Thread Tim Peters
[Tony Meyer] > I have (unfortunately) a Python program that I can consistently (in a > reproducible way) segfault. However, I've got somewhat used to Python's > very nice habit of protecting me from segfaults and raising exceptions > instead, and am having trouble tracking down the problem. > > Th

Re: Favorite non-python language trick?

2005-06-27 Thread Tim Peters
[Terry Hancock] > Probably the most pointless Python wart, I would think. The =/== > distinction makes sense in C, but since Python doesn't allow assignments > in expressions, I don't think there is any situation in which the distinction > is needed. Python could easily figure out whether you mean

Re: %g and fpformat.sci()

2005-06-30 Thread Tim Peters
[Sivakumar Bhaskarapanditha] > How can I control the number of digits after the decimal point using the %g > format specifier. You cannot. See a C reference for details; in general, %g is required to truncate trailing zeroes, and in %.g the is the maximum number of significant digits displayed (

Re: Determining actual elapsed (wall-clock) time

2005-07-02 Thread Tim Peters
[Peter Hansen] > Hmmm... not only that, but at least under XP the return value of > time.time() _is_ UTC. At least, it's entirely unaffected by the > daylight savings time change, or (apparently) by changes in time zone. On all platforms, time.time() returns the number of seconds "since the epoch

Re: math.nroot [was Re: A brief question.]

2005-07-03 Thread Tim Peters
[Fredrik Johansson] >>> I'd rather like to see a well implemented math.nthroot. 64**(1/3.0) >>> gives 3.9996, and this error could be avoided. [Steven D'Aprano] >> >>> math.exp(math.log(64)/3.0) >> 4.0 >> >> Success!!! [Tom Anderson] > Eeenteresting. I have no idea why this works.

Re: math.nroot [was Re: A brief question.]

2005-07-03 Thread Tim Peters
[Steven D'Aprano] ... > But this works: > > py> inf = float("inf") > py> inf > inf Another platform-dependent accident. That does not work, for example, on Windows. In fact, the Microsoft C float<->string routines don't support any way "to spell infinity" that works in the string->float directi

Re: math.nroot [was Re: A brief question.]

2005-07-03 Thread Tim Peters
... [Tom Anderson] > So, is there a way of generating and testing for infinities and NaNs > that's portable across platforms and versions of python? Not that I know of, and certainly no simple way. > If not, could we perhaps have some constants in the math module for them? See PEP 754 for this.

Re: math.nroot [was Re: A brief question.]

2005-07-05 Thread Tim Peters
[Tim Peters] >> All Python behavior in the presence of infinities, NaNs, and signed >> zeroes is a platform-dependent accident, mostly inherited from that >> all C89 behavior in the presence of infinities, NaNs, and signed >> zeroes is a platform-dependent crapshoot. [

Re: math.nroot [was Re: A brief question.]

2005-07-07 Thread Tim Peters
[Tim Peters] >>>> All Python behavior in the presence of infinities, NaNs, and signed >>>> zeroes is a platform-dependent accident, mostly inherited from that >>>> all C89 behavior in the presence of infinities, NaNs, and signed >>>> zeroes is

Re: PPC floating equality vs. byte compilation

2005-07-09 Thread Tim Peters
[Donn Cave] > I ran into a phenomenon that seemed odd to me, while testing a > build of Python 2.4.1 on BeOS 5.04, on PowerPC 603e. > > test_builtin.py, for example, fails a couple of tests with errors > claiming that apparently identical floating point values aren't equal. > But it only does that

Re: math.nroot [was Re: A brief question.]

2005-07-11 Thread Tim Peters
[Tim Peters] >>>>>> All Python behavior in the presence of infinities, NaNs, and signed >>>>>> zeroes is a platform-dependent accident, mostly inherited from that >>>>>> all C89 behavior in the presence of infinities, NaNs, and signed >

Re: Tricky Dictionary Question from newbie

2005-07-12 Thread Tim Peters
[Peter Hansen] ... > I suppose I shouldn't blame setdefault() itself for being poorly named, No, you should blame Guido for that . > but it's confusing to me each time I see it in the above, because the > name doesn't emphasize that the value is being returned, and yet that > fact is arguably mor

Re: math.nroot [was Re: A brief question.]

2005-07-12 Thread Tim Peters
[Michael Hudson] > I doubt anyone else is reading this by now, so I've trimmed quotes > fairly ruthlessly :) Damn -- there goes my best hope at learning how large a message gmail can handle before blowing up . OK, I'll cut even more. [Michael] >>> Can't we use the stuff defined in Appendix F and

Re: math.nroot [was Re: A brief question.]

2005-07-13 Thread Tim Peters
[Steven D'Aprano] > (All previous quoting ruthlessly snipped.) And ruthlessly appreciated ;-) > A question for Tim Peters, as I guess he'll have the most experience in > this sort of thing. > > With all the cross-platform hassles due to the various C compilers no

Re: Why does python break IEEE 754 for 1.0/0.0 and 0.0/0.0?

2005-07-14 Thread Tim Peters
[Grant Edwards] > I've read over and over that Python leaves floating point > issues up to the underlying platform. > > This seems to be largely true, but not always. My underlying > platform (IA32 Linux) correctly handles 1.0/0.0 and 0.0/0.0 > according to the IEEE 754 standard, but Python goes o

Re: Why does python break IEEE 754 for 1.0/0.0 and 0.0/0.0?

2005-07-14 Thread Tim Peters
[Tim Peters] ... >> What does your platform C return for the integer expression >> 42/0? Is any other outcome "wrong"? [Grant Edwards] > I guess I though it was obvious from my reference to IEEE 754 > that I was referring to floating point operations. Yes, that was

Re: Why does python break IEEE 754 for 1.0/0.0 and 0.0/0.0?

2005-07-14 Thread Tim Peters
[Grant Edwards] >> 1/0 is defined by the standard as +Inf and 0/0 is NaN. [Martin v. Löwis] > I wonder why Tim hasn't protested here: Partly because this thread (unlike the other current thread on the topic) isn't moving toward making progress, and I have little time for this. But mostly becaus

Re: math.nroot [was Re: A brief question.]

2005-07-14 Thread Tim Peters
[Michael Hudson] >>>>> In what way does C99's fenv.h fail? Is it just insufficiently >>>>> available, or is there some conceptual lack? [Tim Peters] >>>> Just that it's not universally supported. Look at fpectlmodule.c for >>>> a

Re: time.time() under load between two machines

2005-07-22 Thread Tim Peters
[EMAIL PROTECTED] > I am seeing negative latencies of up to 1 second. I am using ntp to > synchronize both machines at an interval of 2 seconds, so the clocks > should be very much in sync (and are from what I have observed). I > agree that it is probably OS, perhaps I should hop over to a Micro

Re: Ten Essential Development Practices

2005-07-29 Thread Tim Peters
[Steve Holden] >> If I canpoint out the obvious, the output from "import this" *is* >> headed "The Zen of Python", so clearly it isn;t intended to be >> universal in its applicability. [Michael Hudson] > It's also mistitled there, given that it was originally posted as '19 > Pythonic Theses' and n

Re: Ten Essential Development Practices

2005-07-29 Thread Tim Peters
[Dan Sommers] > Ok, not universal. But as usual, Zen is not easily nailed to a tree. > > Was Tim writing about developing Python itself, or about developing > other programs with Python? Tim was channeling Guido, and that's as far as our certain knowledge can go. It _seems_ reasonable to believ

Re: issues with doctest and threads

2005-08-08 Thread Tim Peters
[Michele Simionato] > I am getting a strange error with this script: > > $ cat doctest-threads.py > """ > >>> import time, threading > >>> def example(): > ... thread.out = [] > ... while thread.running: > ... time.sleep(.01) > ... thread.out.append(".") > >>> thread = threa

Re: issues with doctest and threads

2005-08-09 Thread Tim Peters
[Michele Simionato] > Thank you for your replies Jeff & Tim. The snippet I submitted is > unfortunate, since I was writing an example (for a Python course I am > going to give in September) to show that you cannot reliably assume > that you will get exactly 9 dots, because of the limitations of 'sl

Re: String functions deprication

2005-08-16 Thread Tim Peters
[steve morin] > http://www.python.org/doc/2.4.1/lib/node110.html > > These methods are being deprecated. What are they being replaced > with? Does anyone know? As it says at the top of that page, The following list of functions are also defined as methods of string and Unicode objects;

Re: Question about threading.Lock().aquire(waitflag)

2005-08-30 Thread Tim Peters
[EMAIL PROTECTED] > is treated as a boolean or as a number. > > Running on Windows, I get two different behaviors from > the following calls to acquire: > > aLock = threading.Lock() > ... > > # Thread 0 > # This one often succeeds > aLock.acquire(1) > ... > > # Thread 1 > # When

Re: OpenSource documentation problems

2005-09-02 Thread Tim Peters
[Paul Rubin] > Until not that long ago, it was possible to submit sf bugs without > being logged into sf. Why did that change? To reduce tracker spam, to reduce tracker vandalism, and to make it possible to contact submitters when needed. -- http://mail.python.org/mailman/listinfo/python-list

Re: List of integers & L.I.S.

2005-09-08 Thread Tim Peters
[EMAIL PROTECTED] > So, this has no real world use, aside from posting it on a website. > Thanks for wasting our time. You are making up an arbitrary problem and > asking for a solution, simply because you want to look at the > solutions, not because your problem needs to be solved. Clearly, this >

Re: visit_decref: Assertion `gc->gc.gc_refs != 0' failed.

2005-09-09 Thread Tim Peters
[alexLIGO] > I got this error when trying to execute the following python command > with in a C module: Py_BuildValue > > Do anyone have any idea what this error is about? Just the comment on the failing assert: assert(gc->gc.gc_refs != 0); /* else refcount was too small */ There are more p

Re: List of integers & L.I.S. (SPOILER)

2005-09-10 Thread Tim Peters
[Bryan Olson, on the problem at http://spoj.sphere.pl/problems/SUPPER/ ] > I never intended to submit this program for competition. The > contest ranks in speed order, and there is no way Python can > compete with truly-compiled languages on such low-level code. > I'd bet money that the algorit

  1   2   3   4   >