Re: [Python-Dev] bytes.from_hex()

2006-03-02 Thread Stephen J. Turnbull
> "Greg" == Greg Ewing <[EMAIL PROTECTED]> writes: Greg> (BTW, doesn't the fact that you *can* load an XML file into Greg> what we call a "text editor" say something?) Why not answer that question for yourself, and then turn that answer into a description of "text semantics"? For me,

Re: [Python-Dev] C++ for CPython 3? (Re: str.count is slow)

2006-03-02 Thread martin
Zitat von "Stephen J. Turnbull" <[EMAIL PROTECTED]>: > martin> - increased type-safety, in particular for API that isn't > martin> type-checked at all at the moment (e.g. PyArg_ParseTuple) > > That's merely an advantage to having a C++ *compiler*. No need to > actually use the C++ *langua

Re: [Python-Dev] C++ for CPython 3? (Re: str.count is slow)

2006-03-02 Thread martin
Zitat von Greg Ewing <[EMAIL PROTECTED]>: > A rather heavyweight solution to a problem that does > not seem to have been a problem in practice so far, > only in theory. The problem does exist in practice. Python is deliberately build with -fno-strict-aliasing when GCC is used, and might get compi

Re: [Python-Dev] C++ for CPython 3? (Re: str.count is slow)

2006-03-02 Thread martin
Zitat von Fredrik Lundh <[EMAIL PROTECTED]>: > > I'm not saying Python 3 should be written in C++, I'm only saying > > that doing so would have not just disadvantages. > > someone also pointed out in private mail (I think; it doesn't seem to > have made it to this list) that CPython's extensive us

Re: [Python-Dev] bytes.from_hex()

2006-03-02 Thread Greg Ewing
Stephen J. Turnbull wrote: > What you presumably meant was "what would you consider the proper type > for (P)CDATA?" No, I mean the whole thing, including all the <...> tags etc. Like you see when you load an XML file into a text editor. (BTW, doesn't the fact that you *can* load an XML file into

Re: [Python-Dev] bytes thoughts

2006-03-02 Thread Baptiste Carvello
Greg Ewing a écrit : > Why not just support bitwise operations directly > on the bytes object? > Sure, what counts is that all the nice features that Python has for editing binary data are usable with the bytes object. These include bitwise operations, hex() and oct() representation functions an

Re: [Python-Dev] C++ for CPython 3? (Re: str.count is slow)

2006-03-02 Thread Greg Ewing
Fredrik Lundh wrote: > someone also pointed out in private mail (I think; it doesn't seem to > have made it to this list) that CPython's extensive use of "inheritance > by aggregation" is invalid C. > > switching to C++ would be one way to address that, of course. A rather heavyweight solution t

Re: [Python-Dev] bytes.from_hex()

2006-03-02 Thread Greg Ewing
Ron Adam wrote: > This uses syntax to determine the direction of encoding. It would be > easier and clearer to just require two arguments or a tuple. > > u = unicode(b, 'encode', 'base64') > b = bytes(u, 'decode', 'base64') The point of the exercise was to avoid using the terms 'en

Re: [Python-Dev] bytes.from_hex()

2006-03-02 Thread Delaney, Timothy (Tim)
Delaney, Timothy (Tim) wrote: > unicode.frombytes(cls, encoding) unicode.frombytes(encoding) ... Tim Delaney ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/m

Re: [Python-Dev] bytes.from_hex()

2006-03-02 Thread Delaney, Timothy (Tim)
Just van Rossum wrote: > My preference for bytes -> unicode -> bytes API would be this: > > u = unicode(b, "utf8") # just like we have now > b = u.tobytes("utf8") # like u.encode(), but being explicit > # about the resulting type +1 - I was going to write e

Re: [Python-Dev] Making staticmethod objects callable?

2006-03-02 Thread Fredrik Lundh
Guido van Rossum wrote: > I don't see how adding featuers that nobody uses helps. the amount of odd staticmethod uses you see on comp.lang.python these days is staggering. ___ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mai

Re: [Python-Dev] Making staticmethod objects callable?

2006-03-02 Thread Guido van Rossum
On 3/1/06, Nicolas Fleury <[EMAIL PROTECTED]> wrote: > Guido van Rossum wrote: > > In which context did you find a need for defining a static method and > > calling it inside the class definition? I'm guessing that what you're > > playing dubious scoping games. > > I'm not. I almost never use stat

Re: [Python-Dev] ref leak w/except hooks

2006-03-02 Thread Brett Cannon
On 3/2/06, Brett Cannon <[EMAIL PROTECTED]> wrote: > On 3/2/06, Neal Norwitz <[EMAIL PROTECTED]> wrote: > > The following code leaks a reference. Original test case from > > Lib/test/test_sys.py in test_original_excepthook. > > > > import sys, StringIO > > eh = sys.__excepthook__ > > try: > > ra

Re: [Python-Dev] ref leak w/except hooks

2006-03-02 Thread Brett Cannon
On 3/2/06, Neal Norwitz <[EMAIL PROTECTED]> wrote: > The following code leaks a reference. Original test case from > Lib/test/test_sys.py in test_original_excepthook. > > import sys, StringIO > eh = sys.__excepthook__ > try: > raise ValueError(42) > except ValueError, exc: > exc_type, exc_valu

Re: [Python-Dev] bytes.from_hex()

2006-03-02 Thread Stephen J. Turnbull
> "Greg" == Greg Ewing <[EMAIL PROTECTED]> writes: Greg> But the base64 string itself *does* have text semantics. What do you mean by that? The strings of abstract "characters" defined by RFC 3548 cannot be concatenated in general, they may only be split at 4-character intervals, they ca

Re: [Python-Dev] bytes.from_hex()

2006-03-02 Thread Josiah Carlson
Just van Rossum <[EMAIL PROTECTED]> wrote: > > Ron Adam wrote: > > > Josiah Carlson wrote: > > > Greg Ewing <[EMAIL PROTECTED]> wrote: > > >>u = unicode(b) > > >>u = unicode(b, 'utf8') > > >>b = bytes['utf8'](u) > > >>u = unicode['base64'](b) # encoding > > >>b = bytes(u, '

Re: [Python-Dev] C++ for CPython 3? (Re: str.count is slow)

2006-03-02 Thread Stephen J. Turnbull
> "martin" == martin <[EMAIL PROTECTED]> writes: martin> There are a few advantages [to C++], though, mainly: martin> - increased type-safety, in particular for API that isn't martin> type-checked at all at the moment (e.g. PyArg_ParseTuple) That's merely an advantage to having

Re: [Python-Dev] Arena-freeing obmalloc ready for testing

2006-03-02 Thread Tim Peters
[Tim Peters] >> ... >> However, the new branch isn't predictable, so who knows? [Nick Craig-Wood] > When compiling with gcc at least you could give the compiler a hint, > eg > > http://kerneltrap.org/node/4705 By "the new branch isn't predictable", I mean that there's apparently no way to guess

Re: [Python-Dev] defaultdict and on_missing()

2006-03-02 Thread Aahz
On Thu, Mar 02, 2006, Guido van Rossum wrote: > On 3/2/06, Barry Warsaw <[EMAIL PROTECTED]> wrote: >> On Thu, 2006-03-02 at 07:26 -0800, Aahz wrote: >>> >>> OTOH, my personal style is to always use re.compile() because I can >>> never remember the order of arguments for re.match()/re.search(). >> >

Re: [Python-Dev] defaultdict and on_missing()

2006-03-02 Thread Bill Janssen
> For an example of methods gone horribly wrong, look at Java, where you > have .length, String.length(), and Collection.size(). > Give me len() any day. I believe Ruby has similar confusing diversity > for looping (each/forEach). But Java is plagued with the same disease that hit Modula-3, distru

Re: [Python-Dev] When will regex really go away?

2006-03-02 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > The docstring shows how to use it. Yet another Andrew Kuchling gem > as I recall (or maybe an effbot gem). amk, most likely. and in 92.65% of all cases, switching from "regex" to "re" involves adding \ in front of (, | and ) if they don't already have them, and removi

Re: [Python-Dev] C++ for CPython 3? (Re: str.count is slow)

2006-03-02 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I'm not saying Python 3 should be written in C++, I'm only saying > that doing so would have not just disadvantages. someone also pointed out in private mail (I think; it doesn't seem to have made it to this list) that CPython's extensive use of "inheritance by aggregat

Re: [Python-Dev] defaultdict and on_missing()

2006-03-02 Thread Guido van Rossum
On 3/2/06, Barry Warsaw <[EMAIL PROTECTED]> wrote: > On Thu, 2006-03-02 at 07:26 -0800, Aahz wrote: > > OTOH, my personal style is to always use re.compile() because I can > > never remember the order of arguments for re.match()/re.search(). > > Agreed. I don't have that problem, because the order

Re: [Python-Dev] When will regex really go away?

2006-03-02 Thread skip
Neal> I'll do this, except there are some issues: Neal> * Lib/reconvert.py imports regex. Ok to move regex,regsub,recovert to lib-old? Neal> * ./Demo/pdist/rcslib.py & ./Demo/sockets/mcast.py import regsub ... Neal> * A whole mess of Demos and Tools use regex. What to

Re: [Python-Dev] defaultdict and on_missing()

2006-03-02 Thread Barry Warsaw
On Thu, 2006-03-02 at 07:26 -0800, Aahz wrote: > On Wed, Mar 01, 2006, Guido van Rossum wrote: > > > > Operations with two or more arguments are often better expressed as > > function calls -- for example, map() and filter() don't make much > > sense as methods on callables or sequences. > > OTOH,

Re: [Python-Dev] Arena-freeing obmalloc ready for testing

2006-03-02 Thread Nick Craig-Wood
On Thu, Mar 02, 2006 at 01:43:00AM -0600, Tim Peters wrote: > I'm optimistic, because the new test compares a quantity already being > tested by the macro, a second time against 0, and it's hard to get > cheaper than that. However, the new branch isn't predictable, so who > knows? When compiling

Re: [Python-Dev] defaultdict and on_missing()

2006-03-02 Thread Aahz
On Wed, Mar 01, 2006, Guido van Rossum wrote: > > Operations with two or more arguments are often better expressed as > function calls -- for example, map() and filter() don't make much > sense as methods on callables or sequences. OTOH, my personal style is to always use re.compile() because I ca

Re: [Python-Dev] ref leak w/except hooks

2006-03-02 Thread Aahz
On Thu, Mar 02, 2006, Neal Norwitz wrote: > > The following code leaks a reference. Original test case from > Lib/test/test_sys.py in test_original_excepthook. Did you submit a SF bug report? -- Aahz ([EMAIL PROTECTED]) <*> http://www.pythoncraft.com/ "19. A language that does

Re: [Python-Dev] bytes thoughts

2006-03-02 Thread Nick Coghlan
Greg Ewing wrote: > Baptiste Carvello wrote: > >> while manipulating binary data will happen mostly with bytes objects, some >> operations are better done with ints, like the bit manipulations with the >> &|~^ >> operators. > > Why not just support bitwise operations directly > on the bytes ob

Re: [Python-Dev] bytes.from_hex()

2006-03-02 Thread Just van Rossum
Ron Adam wrote: > Josiah Carlson wrote: > > Greg Ewing <[EMAIL PROTECTED]> wrote: > >>u = unicode(b) > >>u = unicode(b, 'utf8') > >>b = bytes['utf8'](u) > >>u = unicode['base64'](b) # encoding > >>b = bytes(u, 'base64') # decoding > >>u2 = unicode['piglatin'](u1) #

[Python-Dev] ref leak w/except hooks

2006-03-02 Thread Neal Norwitz
The following code leaks a reference. Original test case from Lib/test/test_sys.py in test_original_excepthook. import sys, StringIO eh = sys.__excepthook__ try: raise ValueError(42) except ValueError, exc: exc_type, exc_value, exc_tb = sys.exc_info() eh(exc_type, None, None) __

Re: [Python-Dev] Arena-freeing obmalloc ready for testing

2006-03-02 Thread Fredrik Lundh
Tim Peters wrote: > For simpler fun, run this silly little program, and look at memory > consumption at the prompts: > > """ > x = [] > for i in xrange(100): >x.append([]) > raw_input("full ") > del x[:] > raw_input("empty ") > """ > > For example, in a release build on WinXP, VM size is a

Re: [Python-Dev] Arena-freeing obmalloc ready for testing

2006-03-02 Thread Tim Peters
[Tim Peters] ... > Only obmalloc.c is changed in that branch, and you can get it directly from: > > > Heck no -- sorry, that pins it to an out-of-date revision. Use the shorter

Re: [Python-Dev] bytes.from_hex()

2006-03-02 Thread Ron Adam
Josiah Carlson wrote: > Greg Ewing <[EMAIL PROTECTED]> wrote: >>u = unicode(b) >>u = unicode(b, 'utf8') >>b = bytes['utf8'](u) >>u = unicode['base64'](b) # encoding >>b = bytes(u, 'base64') # decoding >>u2 = unicode['piglatin'](u1) # encoding >>u1 = unicode(u2, '