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, 'piglatin') #

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: http://svn.python.org/view/python/branches/tim-obmalloc/Objects/obmalloc.c?rev=42760view=log Heck no -- sorry, that pins it to an out-of-date revision. Use the shorter

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 about 48MB at the full

[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] 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) # encoding u1 =

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 object? +1!

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 doesn't

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 can

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] 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 do

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 is the

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 removing \

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(). Agreed. I

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 which

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

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 to a

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 and

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 what

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 use of

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 compiled

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++ *language*. :-)

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, it says that,