Re: [Python-Dev] Rounding float to int directly (Re: struct module and coercing floats to integers)

2006-07-31 Thread Greg Ewing
Raymond Hettinger wrote: > I think this would harm more than it would help. It more confusing to > have several rounding-thingies to choose from than it is have an > explicit two-step. But is it more confusing enough to be worth forcing everyone to pay two function calls instead of one in the

Re: [Python-Dev] Rounding float to int directly (Re: struct module and coercing floats to integers)

2006-08-01 Thread Greg Ewing
M.-A. Lemburg wrote: > I suppose you don't know about the optional argument > to round that lets you round up to a certain decimal ?! Yes, I know about, but I rarely if ever use it. Rounding a binary float to a number of decimal places seems a fundamentally ill-considered thing to do anyway. What

Re: [Python-Dev] Rounding float to int directly (Re: struct module and coercing floats to integers)

2006-08-01 Thread Greg Ewing
M.-A. Lemburg wrote: > You often have a need for controlled rounding when doing > financial calculations You should NOT be using binary floats for money in the first place. > or in situations where you want to > compare two floats with a given accuracy, Pseudo-rounding to decimal places is n

Re: [Python-Dev] Rounding float to int directly ...

2006-08-02 Thread Greg Ewing
Nick Maclaren wrote: > I am unaware of > any technical grounds to prefer one over the other (i.e. the reasons > for wanting each are equally balanced). If they're equally balanced in the sense of there being equal numbers of use cases for both, that would seem to be a reason to *have* both. What'

Re: [Python-Dev] Rounding float to int directly ...

2006-08-02 Thread Greg Ewing
Michael Chermside wrote: > (Why you would WANT > more than around 53 bits of precision is a different question, but > Decimal handles it.) You can't have travelled far beyond Alpha Centauri recently. The major interstellar banking corporations need *quite* a lot of bits for dealing with the econom

Re: [Python-Dev] Rounding float to int directly ...

2006-08-02 Thread Greg Ewing
Nick Coghlan wrote: > Another option would be to provide this as a method of float objects > (similar to decimal). That wouldn't be so good. Either kind of rounding ought to be a function that you can apply without knowing what kind of number you've got -- int, float, Decimal, or something else.

Re: [Python-Dev] Rounding float to int directly (Re: struct module and coercing floats to integers)

2006-08-02 Thread Greg Ewing
M.-A. Lemburg wrote: > Believe me: you have to if you want to do more > advanced calculus related to pricing and risk > analysis of derivatives. When you do things like that, you're treating money as though it were a continuous quantity. This is an approximation, so you can tolerate having small

Re: [Python-Dev] Rounding float to int directly (Re: struct module and coercing floats to integers)

2006-08-02 Thread Greg Ewing
Raymond Hettinger wrote: > -1 on an extra built-in just to save the time for function call The time isn't the main issue. The main issue is that almost all the use cases for round() involve doing an int() on it afterwards. At least nobody has put forward an argument to the contrary yet. Sure you

Re: [Python-Dev] Rounding float to int directly (Re: struct module and coercing floats to integers)

2006-08-03 Thread Greg Ewing
M.-A. Lemburg wrote: > If you are eventually rounding to say 2 decimal > places in the end of the calculation, you won't > want to find yourself presenting the user 1.12 > and 1.13 as equal values :-) Even if, before rounding, they were actually 1.124 and 1.1251? And if the differ

Re: [Python-Dev] unicode hell/mixing str and unicode as dictionary keys

2006-08-03 Thread Greg Ewing
M.-A. Lemburg wrote: > Perhaps we ought to add an exception to the dict lookup mechanism > and continue to silence UnicodeErrors ?! Seems to be that comparison of unicode and non-unicode strings for equality shouldn't raise exceptions in the first place. -- Greg _

Re: [Python-Dev] Rounding float to int directly (Re: struct module and coercing floats to integers)

2006-08-04 Thread Greg Ewing
James Y Knight wrote: > And it does in C because C doesn't have arbitrary size integers, so if > round returned integers, round(1e+308) couldn't work. Also, in C you can use the result directly in an int context without complaint. In Python these days, that is usually disallowed. -- Greg _

Re: [Python-Dev] unicode hell/mixing str and unicode as dictionary keys

2006-08-04 Thread Greg Ewing
M.-A. Lemburg wrote: > If a string > is not ASCII and thus causes the exception, there's not a lot you > can say, since you don't know the encoding of the string. That's one way of looking at it. Another is that any string containing chars > 127 is not text at all, but binary data, in which case

Re: [Python-Dev] Dicts are broken Was: unicode hell/mixing str and unicode asdictionarykeys

2006-08-08 Thread Greg Ewing
M.-A. Lemburg wrote: > Hiding programmer errors is not making life easier in the > long run, so I'm -1 on having the equality comparison return > False. I don't see how this is greatly different from, e.g. [1, 2] == (1, 2) returning False. Comparing things of different types may or may not i

Re: [Python-Dev] openSSL and windows binaries - license

2006-08-08 Thread Greg Ewing
Martin v. Löwis wrote: > I personally don't think there is a risk > distributing the code (if there was, distribution of OpenSSL would also > be a risk); anybody /using/ a patented algorithm would violate the > patent. If distributing the source doesn't violate the patent, and distributing a binar

Re: [Python-Dev] openSSL and windows binaries - license

2006-08-09 Thread Greg Ewing
Martin v. Löwis wrote: > In the context of an encryption algorithm, the right to > use would be the most prominent one; you wouldn't be > allowed to use the algorithm unless you have a patent > license. But what does "use" *mean* in relation to an algorithm? -- Greg _

Re: [Python-Dev] openSSL and windows binaries - license

2006-08-10 Thread Greg Ewing
Martin v. Löwis wrote: > Perform it: do the steps that the algorithm says you should > do, or let a machine do it. IOW, run the code. That can't be right, because it would mean that anyone who runs a program that contains a patented algorithm, even one bought or otherwise obtained from someone el

[Python-Dev] Is module clearing still necessary? [Re: Is this a bug?]

2006-08-10 Thread Greg Ewing
Nick Coghlan wrote: > Early versions of the PEP 338 implementation also ran into the problem of a > module's globals getting cleared when the module itself goes away A while back it was suggested that the module-clearing thing might be dropped now that we have cyclic GC, but I don't remember the

Re: [Python-Dev] SyntaxError: can't assign to function call

2006-08-10 Thread Greg Ewing
Michael Urman wrote: > Just to play devil's advocate here, why not to a function call via a > new __setcall__? You still haven't answered the question of what this buys you over just giving your object a suitably named method that does whatever your __setcall__ method would have done. Can you sh

[Python-Dev] Split augmented assignment into two operator sets? [Re: SyntaxError: can't assign to function call]

2006-08-10 Thread Greg Ewing
n arrays concisely. The +: family would fill this need. PPS: Yes, I know the use of : might be ill-advised. It's just an example - any other concise notation would do as well. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury,

[Python-Dev] NotHashableError? (Re: dict containment annoyance)

2006-08-13 Thread Greg Ewing
Guido van Rossum wrote: > try: > hash(x) > except TypeError: > # apparently x is not hashable > > then you're also swallowing any type errors in the computation of a > legitimate hash function. Maybe it would help if there were a specific exception, such as NotHashableError, that hash functi

Re: [Python-Dev] Type of range object members

2006-08-15 Thread Greg Ewing
Martin v. Löwis wrote: > We had this discussion before; if you use ob_size==0 to indicate > that it's an int, this space isn't needed in a long int. What about int subclasses? -- Greg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.

Re: [Python-Dev] Type of range object members

2006-08-15 Thread Greg Ewing
Guido van Rossum wrote: > I worry that dropping the special allocator will be too slow. Surely there's some compromise that would allow recently-used ints to be kept around, but reclaimed if memory becomes low? -- Greg ___ Python-Dev mailing list Python

Re: [Python-Dev] Type of range object members

2006-08-15 Thread Greg Ewing
Guido van Rossum wrote: > On 8/15/06, James Y Knight <[EMAIL PROTECTED]> wrote: > >>There's no particular reason that a short int must be able to store >>the entire range of C "long", so, as many bits can be stolen from it >>as desired. > > There isn't? Actually a lot of APIs currently assumen t

Re: [Python-Dev] Type of range object members

2006-08-16 Thread Greg Ewing
Martin v. Löwis wrote: > Greg Ewing schrieb: >>Also it means you'd pay a penalty every time you >>access it > > That penalty is already paid today. You'd still have that penalty, *plus* the overhead of bit masking to get at the value. Maybe that wouldn'

Re: [Python-Dev] Making 'python -t' the default.

2006-08-16 Thread Greg Ewing
Georg Brandl wrote: > Or disallow tabs altogether. -1. I'd be annoyed if Python started telling me I wasn't allowed to write my source the way my preferred editor (BBEdit) works best. Very annoyed. -- Greg ___ Python-Dev mailing list Python-Dev@python

Re: [Python-Dev] Doc suggestion for Elementtree (for 2.5? a bit late, I know...)

2006-08-28 Thread Greg Ewing
Paul Moore wrote: > The ElementTree module comes in two forms - a pure-python version > (xml.etree.ElementTree) and a C-coded implementation > (xml.etree.cElementTree) which is faster. If this is to be in the stdlib, is there any chance of tidying up the convoluted, uninituitive and non-pep8-comp

Re: [Python-Dev] Doc suggestion for Elementtree (for 2.5? a bitlate, I know...)

2006-08-29 Thread Greg Ewing
Fredrik Lundh wrote: > ET was written years before the "certain modules should use camelcase" stuff > was removed from PEP 8. Maybe so, but I was hoping that additions to the stdlib in this day and age might be adapted to follow modern conventions instead of just being plonked in as-is. -- Greg

Re: [Python-Dev] Adding an rslice() builtin?

2006-08-29 Thread Greg Ewing
Nick Coghlan wrote: >reversed(seq[start:stop:step]) becomes > seq[(stop-1)%abs(step):start-1:-step] > > An rslice builtin would make the latter version significantly easier to read: > >seq[rslice(start, stop, step)] How would this deal with omitted start and/or stop values? -- Greg __

Re: [Python-Dev] Signals, threads, blocking C functions

2006-09-10 Thread Greg Ewing
Jan Kanis wrote: > However, PyGTKs problem does get > solved, as long as there is _a_ thread that returns to the interpreter > within some timeframe. It seems plausible that this will happen. I don't see that this makes the situation much better, as it just shifts the need for polling to anoth

Re: [Python-Dev] Py_BuildValue and decref

2006-09-10 Thread Greg Ewing
Barry Warsaw wrote: > I just want to point out that the C API documentation is pretty > silent about the refcounting side-effects in error conditions (and > often in success conditions too) of most Python functions. For > example, what is the refcounting side-effects of PyDict_SetItem() on

Re: [Python-Dev] Py_BuildValue and decref

2006-09-11 Thread Greg Ewing
ur differs when it fails is awkward to use safely at best, impossible at worst (if there's no way of finding out what needs to be decrefed in order to clean up properly).] -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury,

Re: [Python-Dev] Signals, threads, blocking C functions

2006-09-11 Thread Greg Ewing
that buffer may fill and > we lose signals. That might be an argument for *not* trying to communicate the signal number by the value written to the pipe, but keep a separate set of signal-pending flags, and just use the pipe as a way of indicating that *something* has happened. -- Greg Ewing, C

Re: [Python-Dev] Signals, threads, blocking C functions

2006-09-11 Thread Greg Ewing
Adam Olsen wrote: > That brings you back to how you access the flags variable. The existing signal handler sets a flag, doesn't it? So it couldn't be any more broken than the current implementation. If we get too paranoid about this, we'll just end up deciding that signals can't be used for anyt

Re: [Python-Dev] Grammar change in classdef

2006-09-16 Thread Greg Ewing
Talin wrote: > Is the result a new-style or classic-style class? It would be nice if > using the empty parens forced a new-style class... No, it wouldn't, IMO. Too subtle a clue. Best to just wait for Py3k when all classes will be new-style. -- Greg _

Re: [Python-Dev] New relative import issue

2006-09-18 Thread Greg Ewing
system structure. There really shouldn't be any such thing as sys.path -- the view that any given module has of the package namespace should depend only on where it is, not on the history of how it came to be invoked. -- Greg Ewing, Computer Science Dept, +--

Re: [Python-Dev] deja-vu .. python locking

2006-09-18 Thread Greg Ewing
7;s sufficient to be able to lock just one object at a time. Maybe it is, but some more formal consideration of that might be a good idea. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | Carpe post meridiem! | Chris

Re: [Python-Dev] deja-vu .. python locking

2006-09-18 Thread Greg Ewing
ct. What *looks* like read-only access at the Python level involves refcount updates just from the act of touching the object. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | Carpe post meridiem! | Christchurch, N

Re: [Python-Dev] deja-vu .. python locking

2006-09-18 Thread Greg Ewing
o go through the relevant motions, and see what timings are produced for single-threaded code. It wouldn't be a working implementation, but you'd find out pretty quickly if it were going to be a disaster. -- Greg Ewing, Computer Science Dept, +--

Re: [Python-Dev] deja-vu .. python locking

2006-09-19 Thread Greg Ewing
Martin Devera wrote: > Greg, what change do you have in mind regarding that "3 instruction > addition" to refcounting ? I don't have any change in mind. If even an atomic inc is too expensive, it seems there's no hope for us. -- Greg ___ Python-Dev mai

Re: [Python-Dev] New relative import issue

2006-09-19 Thread Greg Ewing
Steve Holden wrote: > This does, of course, assume that you're importing modules from the > filestore, which assumption is no longer valid in the presence of PEP > 302 importers. Well, you need to allow for a sufficiently abstract notion of "filesystem". I haven't really thought it through in

Re: [Python-Dev] New relative import issue

2006-09-21 Thread Greg Ewing
Guido van Rossum wrote: > Eek? If there are two third-party top-level packages A and B, by > different third parties, and A depends on B, how should A find B if > not via sys.path or something that is sufficiently equivalent as to > have the same problems? Some kind of configuration mechanism is

Re: [Python-Dev] New relative import issue

2006-09-21 Thread Greg Ewing
Another thought on static module namespace configuration: It would make things a *lot* easier for py2exe, py2app and the like that have to figure out what packages a program depends on without running the program. -- Greg ___ Python-Dev mailing list Pyth

Re: [Python-Dev] New relative import issue

2006-09-21 Thread Greg Ewing
Giovanni Bajo wrote: > My idea (and interpretation of Greg's statement) is that a module/package > should be able to live with either relative imports within itself, or fully > absolute imports. I think it goes further than that -- each module should (potentially) have its own unique view of the

[Python-Dev] list.discard? (Re: dict.discard)

2006-09-21 Thread Greg Ewing
Gustavo Niemeyer wrote: > >>> print set.discard.__doc__ > Remove an element from a set if it is a member. Actually I'd like this for lists. Often I find myself writing if x not in somelist: somelist.remove(x) A single method for doing this would be handy, and more efficient. -- Gre

Re: [Python-Dev] New relative import issue

2006-09-21 Thread Greg Ewing
Guido van Rossum wrote: > While I agree with your idea(l), I don't think that's what Greg meant. > He clearly say "sys.path should not exist at all". Refining that a bit, I don't think there should be a *single* sys.path for the whole program -- more like each module having its own sys.path. And,

Re: [Python-Dev] list.discard? (Re: dict.discard)

2006-09-22 Thread Greg Ewing
[EMAIL PROTECTED] wrote: > It's obvious for sets and dictionaries that there is only one thing to > discard and that after the operation you're guaranteed the key no longer > exists. Would you want the same semantics for lists or the semantics of > list.remove where it only removes the first inst

Re: [Python-Dev] weakref enhancements

2006-09-28 Thread Greg Ewing
Raymond Hettinger wrote: > Also, I question the utility of maintaining a weakref to a method or > attribute instead of holding one for the object or class. As long as > the enclosing object or class lives, so too will their methods and > attributes. So what is the point of a tighter weakref gr

Re: [Python-Dev] Python Doc problems

2006-09-28 Thread Greg Ewing
Barry Warsaw wrote: > There's also the pull between wanting to write reference docs for > those who know what they've forgotten (I love that phrase!) and > writing the introductory or "how it hangs together" documentation. The trick to this, I think, is not to try to make the same piece of d

Re: [Python-Dev] Caching float(0.0)

2006-09-29 Thread Greg Ewing
Nick Craig-Wood wrote: > Is there any reason why float() shouldn't cache the value of 0.0 since > it is by far and away the most common value? 1.0 might be another candidate for cacheing. Although the fact that nobody has complained about this before suggests that it might not be a frequent enou

Re: [Python-Dev] OT: How many other people got this spam?

2006-10-01 Thread Greg Ewing
Jack Jansen wrote: > I was wondering: how many other people who maintain websites (well: > "maintain" might be a bit of a misnomer in my case:-) related to > Python have also got this spam? I got it. I was rather amused that they claim to have been "looking for sites that would make good link

Re: [Python-Dev] Cloning threading.py using proccesses

2006-10-11 Thread Greg Ewing
Fredrik Lundh wrote: > if you're aware of a way to do that faster than the current marshal > implementation, maybe you could work on speeding up marshal instead? Even if it weren't faster than marshal, it could still be useful to have something nearly as fast that used a python-version-independe

Re: [Python-Dev] Cloning threading.py using proccesses

2006-10-12 Thread Greg Ewing
Fredrik Lundh wrote: > marshal hasn't changed in many years: Maybe not, but I was given to understand that it's regarded as a private format that's not guaranteed to remain constant across versions. So even if it happens not to change, it wouldn't be wise to rely on that. -- Greg ___

Re: [Python-Dev] PEP 355 status

2006-10-25 Thread Greg Ewing
Talin wrote: > (Actually, the OOP approach has a slight advantage in terms of the > amount of syntactic sugar available, Even if you don't use any operator overloading, there's still the advantage that an object provides a namespace for its methods. Without that, you either have to use fairly ver

Re: [Python-Dev] PEP 355 status

2006-10-25 Thread Greg Ewing
Talin wrote: > Ideally, you should be able to pass > "file:///..." to a regular "open" function. I'm not so sure about that. Consider that "file:///foo.bar" is a valid relative pathname on Unix to a file called "foo.bar" in a directory called "file:". That's not to say there shouldn't be a funct

Re: [Python-Dev] PEP 355 status

2006-10-26 Thread Greg Ewing
Talin wrote: > That's true of textual paths in general - i.e. even on unix, textual > paths aren't guaranteed to be unique or exist. What I mean is that it's possible for two different files to have the same pathname (since you can mount two volumes with identical names at the same time, or for

Re: [Python-Dev] PEP 355 status

2006-10-26 Thread Greg Ewing
Talin wrote: > It seems that any Python program that manipulated paths > would have to be radically different in the environment that you describe. I can sympathise with that. The problem is really inherent in the nature of the platforms -- it's just not possible to do everything in a native clas

Re: [Python-Dev] PEP: Adding data-type objects to Python

2006-10-27 Thread Greg Ewing
Travis E. Oliphant wrote: > PEP: > Title: Adding data-type objects to the standard library Not sure about having 3 different ways to specify the structure -- it smacks of Too Many Ways To Do It to me. Also, what if I want to refer to fields by name but don't want to have to work out all the offs

Re: [Python-Dev] PEP: Adding data-type objects to Python

2006-10-28 Thread Greg Ewing
Nick Coghlan wrote: > Greg Ewing wrote: >> Also, what if I want to refer to fields by name >> but don't want to have to work out all the offsets > Use the list definition form. With the changes I've > suggested above, you wouldn't even have to name the f

Re: [Python-Dev] PEP: Adding data-type objects to Python

2006-10-28 Thread Greg Ewing
Nick Coghlan wrote: > I'd say the answer to where we put it will be dependent on what happens to > the > idea of adding a NumArray style fixed dimension array type to the standard > library. If that gets exposed through the array module as array.dimarray, > then > it would make sense to expose

Re: [Python-Dev] PEP: Adding data-type objects to Python

2006-10-28 Thread Greg Ewing
Travis E. Oliphant wrote: > The 'kind' does not specify how "big" the data-type (data-format) is. What exactly does "bit" mean in that context? -- Greg ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev

Re: [Python-Dev] PEP: Adding data-type objects to Python

2006-10-28 Thread Greg Ewing
Travis E. Oliphant wrote: > How to handle unicode data-formats could definitely be improved. > Suggestions are welcome. 'U4*10' string of 10 4-byte Unicode chars Then for consistency you'd want 'S*10' rather than just 'S10' (or at least allow it as an alternative). -- Greg ___

Re: [Python-Dev] PEP: Adding data-type objects to Python

2006-10-29 Thread Greg Ewing
Travis E. Oliphant wrote: > Greg Ewing wrote: >>What exactly does "bit" mean in that context? > > Do you mean "big" ? No, you've got a data type there called "bit", which seems to imply a size, in contradiction to the size-independe

Re: [Python-Dev] PEP: Adding data-type objects to Python

2006-10-29 Thread Greg Ewing
Travis E. Oliphant wrote: > Martin v. Löwis wrote: > >>Travis E. Oliphant schrieb: >>Is it the intent of this PEP to support such data structures, >>and allow the user to fill in a Unicode object, and then the >>processing is automatic? > No, the point of the data-format object is to communicate

Re: [Python-Dev] PEP: Adding data-type objects to Python

2006-10-29 Thread Greg Ewing
Josiah Carlson wrote: > ...in the cases I have seen ... you _always_ get > them in RGBA order. Except when you don't. I've had cases where I've had to convert between RGBA and BGRA (for stuffing directly into a frame buffer on Linux, as far as I remember). So it may be worth including some featu

Re: [Python-Dev] PEP: Adding data-type objects to Python

2006-10-30 Thread Greg Ewing
Travis Oliphant wrote: > Part of the problem is that ctypes uses a lot of different Python types > (that's what I mean by "multi-object" to accomplish it's goal). What > I'm looking for is a single Python type that can be passed around and > explains binary data. It's not clear that multi-obj

Re: [Python-Dev] PEP: Adding data-type objects to Python

2006-10-30 Thread Greg Ewing
Travis Oliphant wrote: > The 'bit' type re-intprets the size information to be in units of "bits" > and so implies a "bit-field" instead of another data-format. Hmmm, okay, but now you've got another orthogonality problem, because you can't distinguish between e.g. a 5-bit signed int field and a

Re: [Python-Dev] PEP: Adding data-type objects to Python

2006-10-30 Thread Greg Ewing
Travis Oliphant wrote: > I'm not sure I understand what you mean by "incomplete / recursive" > types unless you are referring to something like a node where an element > of the structure is a pointer to another structure of the same kind > (like used in linked-lists or trees). Yes, and more co

Re: [Python-Dev] idea for data-type (data-format) PEP

2006-11-02 Thread Greg Ewing
Alexander Belopolsky wrote: > In ctypes arrays of different > shapes are represented using different types. As a result, if the object > exporting its buffer is resized, the datatype object cannot be reused, it > has to be replaced. I was thinking about that myself the other day. I was thinking t

Re: [Python-Dev] PEP: Extending the buffer protocol to share array information.

2006-11-02 Thread Greg Ewing
Fredrik Lundh wrote: > the "right solution" for things like this is an *API* that lets you do > things like: > > view = object.acquire_view(region, supported formats) And how do you describe the "supported formats"? That's where Travis's proposal comes in, as far as I can see. -- Greg __

Re: [Python-Dev] Path object design

2006-11-02 Thread Greg Ewing
Mike Orr wrote: >> * This is confusing as heck: >> >>> os.path.join("hello", "/world") >> '/world' It's only confusing if you're not thinking of pathnames as abstract entities. There's a reason for this behaviour -- it's so you can do things like full_path = os.path.join(default_dir, fil

Re: [Python-Dev] PEP: Adding data-type objects to Python

2006-11-02 Thread Greg Ewing
Travis Oliphant wrote: > or just > > numpy.array(array.array('d',[1,2,3])) > > and leave-out the buffer object all together. I think the buffer object in his example was just a placeholder for "some arbitrary object that supports the buffer interface", not necessarily another NumPy array. -- Gr

Re: [Python-Dev] idea for data-type (data-format) PEP

2006-11-02 Thread Greg Ewing
Alexander Belopolsky wrote: > That's a question for Travis, but I would think that they would be > immutable at the Python level, but mutable at the C level. Well, anything's mutable at the C level -- the question is whether you *should* be mutating it. I think the datatype object should almost

Re: [Python-Dev] Path object design

2006-11-02 Thread Greg Ewing
[EMAIL PROTECTED] wrote: >>>> os.path.join("hello", "slash/world") >'hello/slash/world' >>>> os.path.join("hello", "slash//world") >'hello/slash//world' >Trying to formulate a general rule for what the arguments to > os.path.join are supposed to be is really hard. If you're s

Re: [Python-Dev] Path object design

2006-11-02 Thread Greg Ewing
Mike Orr wrote: > I have no idea why Microsoft thought it was a good idea to > put the seven-odd device files in every directory. Why not force > people to type the colon ("CON:"). Yes, this is a particularly stupid piece of braindamage on the part of the designers of MS-DOS. As far as I remember,

Re: [Python-Dev] Path object design

2006-11-02 Thread Greg Ewing
[EMAIL PROTECTED] wrote: > Relative > paths, if they should exist at all, should have to be explicitly linked > as relative to something *else* (e.g. made absolute) before they can be > used. If paths were opaque objects, this could be enforced by not having any way of constructing a path that

Re: [Python-Dev] PEP: Adding data-type objects to Python

2006-11-02 Thread Greg Ewing
Travis E. Oliphant wrote: > We have T_UBYTE and T_BYTE, etc. defined > in structmember.h already. Should we just re-use those #defines while > adding to them to make an easy to use interface for primitive types? They're mixed up with size information, though, which we don't want to do. -- Greg

Re: [Python-Dev] idea for data-type (data-format) PEP

2006-11-02 Thread Greg Ewing
Alexander Belopolsky wrote: > My main concern was that in ctypes the size of an array is a part of > the datatype object and this seems to be redundant if used for the > buffer protocol. Buffer protocol already reports the size of the > buffer as a return value of bf_get*buffer methods. I

Re: [Python-Dev] Path object design

2006-11-02 Thread Greg Ewing
Steve Holden wrote: > Greg Ewing wrote: > >>Having said that, I can see there could be an >>element of confusion in calling it "join". >> > > Good point. "relativise" might be appropriate, Sounds like something to make my computer go at warp sp

Re: [Python-Dev] Importing .pyc in -O mode and vice versa

2006-11-04 Thread Greg Ewing
Fredrik Lundh wrote: > well, from a performance perspective, it would be nice if Python looked > for *fewer* things, not more things. Instead of searching for things by doing a stat call for each possible file name, would it perhaps be faster to read the contents of all the directories along sys

Re: [Python-Dev] [Python-3000] Mini Path object

2006-11-05 Thread Greg Ewing
Mike Orr wrote: > .abspath() > .normpath() > .realpath() > .splitpath() > .relpath() > .relpathto() Seeing as the whole class is about paths, having "path" in the method names seems redundant. I'd prefer to see terser method names without any noise characters in them. --

Re: [Python-Dev] Importing .pyc in -O mode and vice versa

2006-11-05 Thread Greg Ewing
Martin v. Löwis wrote: > That should never be better: the system will cache the directory > blocks, also, and it will do a better job than Python will. If that's really the case, then why do discussions of how improve Python startup speeds seem to focus on the number of stat calls made? Also, ca

Re: [Python-Dev] idea for data-type (data-format) PEP

2006-11-05 Thread Greg Ewing
Travis Oliphant wrote: > In NumPy, the data-type objects have function pointers to accomplish all > the things NumPy does quickly. If the datatype object is to be extracted and made a stand-alone feature, that might need to be refactored. Perhaps there could be a facility for traversing a datat

Re: [Python-Dev] Importing .pyc in -O mode and vice versa

2006-11-06 Thread Greg Ewing
Martin v. Löwis wrote: > A stat call will not only look at the directory entry, but also > look at the inode. This will require another disk access, as the > inode is at a different location of the disk. That should be in favour of the directory-reading approach, since e.g. to find out which if a

Re: [Python-Dev] Importing .pyc in -O mode and vice versa

2006-11-07 Thread Greg Ewing
Armin Rigo wrote: It would seem good practice to remove all .pycs after checking out a new version of the source, just in case there are other problems such as mismatched timestamps, which can cause the same trouble. > My two > cents is that it would be saner to have two separate concepts: cache

Re: [Python-Dev] Importing .pyc in -O mode and vice versa

2006-11-07 Thread Greg Ewing
Delaney, Timothy (Tim) wrote: > Would it be reasonable to always do a stat() on the directory, > reloading if there's been a change? Would this be reliable across > platforms? To detect a new shadowing you'd have to stat all the directories along sys.path, not just the one you think the file is

Re: [Python-Dev] Importing .pyc in -O mode and vice versa

2006-11-07 Thread Greg Ewing
Martin v. Löwis wrote: > Currently, you can put a file on disk and import it > immediately; that will stop working. One thing I should add is that if you try to import a module that wasn't there before, the interpreter will notice this and has the opportunity to update its idea of what's on the d

Re: [Python-Dev] Importing .pyc in -O mode and vice versa

2006-11-08 Thread Greg Ewing
Martin v. Löwis wrote: > a) the directory cache is out of date, and you should >re-read the directory > b) the module still isn't there, but is available in >a later directory on sys.path (which hasn't yet >been visited) > c) the module isn't there at all, and the import will >even

Re: [Python-Dev] Python and the Linux Standard Base (LSB)

2006-11-29 Thread Greg Ewing
Barry Warsaw wrote: > I'm not sure I like ~/.local though > - -- it seems counter to the app-specific dot-file approach old > schoolers like me are used to. Problems with that are starting to show, though. There's a particular Unix account that I've had for quite a number of years, accumulatin

Re: [Python-Dev] Python and the Linux Standard Base (LSB)

2006-11-30 Thread Greg Ewing
Barry Warsaw wrote: > When I switched to OS X for most of my desktops, I had several > collisions in this namespace. I think on MacOSX you have to consider that it's really ~/Documents and the like that are *your* namespaces, rather than the top level of your home directory. Also, I think MacO

Re: [Python-Dev] a feature i'd like to see in python #2: indexing of match objects

2006-12-03 Thread Greg Ewing
Steve Holden wrote: > So the subgroups are numbered starting from > 1 and subgroup 0 is a special case which returns the whole match. But the subgroups can be nested too, so it's not really as special as all that. -- Greg ___ Python-Dev mailing list Py

Re: [Python-Dev] [NPERS] Re: a feature i'd like to see in python #2: indexing of match objects

2006-12-04 Thread Greg Ewing
Nick Coghlan wrote: > *The inconsistency being that group() considers the whole match to be group > 0, > while groups() does not. The real inconsistency seems to be that the groups are being treated as an array when they're really a tree. Maybe a different API altogether would be better, e.g.

Re: [Python-Dev] LSB: Binary compatibility

2006-12-05 Thread Greg Ewing
Could backwards compatibility concerns be addressed by including more than one version of Python in the LSB? Python already allows multiple versions to coexist, so applications targeting the LSB would just need to be explicit about which version of the interpreter to launch. -- Greg __

Re: [Python-Dev] Threading, atexit, and logging

2006-12-07 Thread Greg Ewing
has something to do with threading, whereas the atexit mechanism could get screwed up by someone who wasn't even thinking about what effect it might have on threading. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury,

Re: [Python-Dev] Problem with signals in a single threaded application

2007-01-26 Thread Greg Ewing
Martin v. Löwis wrote: > Please > try to come up with a patch (e.g. by putting a while(is_tripped) loop > around the for loop). That isn't going to fix it. What's needed is to somehow atomically test and clear is_tripped at the beginning. You can put a while loop around it as well if you want, bu

Re: [Python-Dev] Problem with signals in a single threaded application

2007-01-26 Thread Greg Ewing
Nick Maclaren wrote: > This one looks like an oversight in Python code, and so is a bug, > but it is important to note that signals do NOT work reliably under > any Unix or Microsoft system. That's a rather pessimistic way of putting it. In my experience, signals in Unix mostly do what they're me

Re: [Python-Dev] Object creation hook

2007-01-26 Thread Greg Ewing
Kristján V. Jónsson wrote: > (I was a bit dismayed that I couldn't assign to object.__init__ > post-hoc from a python script, I'm fairly sure that is possible in Ruby :) It wouldn't do you much good anyway, because no existing subclass of object having its own __init__ method would call it. -

Re: [Python-Dev] Problem with signals in a single threaded application

2007-01-27 Thread Greg Ewing
Martin v. Löwis wrote: > Greg Ewing schrieb: > >>>Please >>>try to come up with a patch (e.g. by putting a while(is_tripped) loop >>>around the for loop). >> >>That isn't going to fix it. > > Why not? Correct me if I'm wrong, but w

Re: [Python-Dev] [Python-3000] Unipath package

2007-01-28 Thread Greg Ewing
say that translation of absolute paths is not supported in general. -- Greg Ewing, Computer Science Dept, +--+ University of Canterbury, | Carpe post meridiem! | Christchurch, New Zealand

Re: [Python-Dev] [Python-3000] Unipath package

2007-01-28 Thread Greg Ewing
m, in which case Unix paths are used for both, or the Unix file system must be mounted on the Windows system, in which case they're both Windows paths. In neither case is a conversion from Unix to Windows pathnames needed. -- Greg Ewing, Computer Science Dept, +

Re: [Python-Dev] Shortcut Notation for Chaining Method Calls

2007-02-03 Thread Greg Ewing
Michael O'Keefe wrote: > I'd like to see a built-in shorthand to allow me to > chain method calls even when a method call does not explicity > return a reference to the instance of the object (self). > def newFunc02(): > return NewList([8,9,7,1]).self_('sort').self_('reverse').self_('pop',0)

<    7   8   9   10   11   12   13   14   15   16   >