Re: [Python-Dev] minidom and DOM level 2
Jason Orendorff wrote: > OK, I think this is worthwhile then. :) I'll read the spec and submit > a patch. You're planning to implement EntityReference in minidom? That'll be fun! :-) One of the nastier corners of DOM and XML in general. > I'd be happy to do some diffing between the implementation, > documentation, tests, and the Recommendation I hacked up an experimental test harness for the W3 DOM Test Suite in order to test my own imp; you might find it useful: http://doxdesk.com/software/py/domts.html The TS is far from definitive, but its tests for Level 1 and 2 are to the best of my knowledge accurate. Incidentally minidom falls far short of passing even Level 1 Core for more reasons than omission of EntityReference. I noted the main known problems with it here: http://pyxml.sourceforge.net/topics/compliance.html Good luck! -- And Clover mailto:[EMAIL PROTECTED] http://www.doxdesk.com/ ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] Extended buffer PEP
Only one concern: > typedef int (*getbufferproc)(PyObject *obj, struct bufferinfo *view) I'd like to see it accept a flags argument over what kind of buffer it's allowed to return. I'd rather not burden the user to check all the entries in bufferinfo to make sure it doesn't get something unexpected. I imagine most uses of buffer protocol would be for direct, one-dimensional arrays of bytes with no striding. It's not clear whether read-only or read-write should be the least common denominator, so require at least one of these flags: Py_BUF_READONLY Py_PUF_READWRITE Then allow any of these flags to allow more complex access: Py_BUF_MULTIDIM - allows strided and multidimensional arrays Py_BUF_INDIRECT - allows indirect buffers (implies Py_BUF_MULTIDIM) An object is allowed to return a simpler array than requested, but not more complex. If you allow indirect buffers, you might still get a one-dimensional array of bytes. Other than that, I would add a note about the other things considered and rejected (the old prototype for getbufferproc, the delegated buffer object). List whether to backport the buffer protocol to 2.6 as an open question. Then submit it as a real PEP. I believe this idea has run its course as PEP XXX and needs a real number. (I was intending to start making patches for the Py3K library modules as soon as that happened.) Carl Banks Travis Oliphant wrote: > > Here is my "final" draft of the extended buffer interface PEP. > For those who have been following the discussion, I eliminated the > releaser object and the lock-buffer function. I decided that there is > enough to explain with the new striding and sub-offsets without the > added confusion of releasing buffers, especially when it is not clear > what is to be gained by such complexity except a few saved lines of code. > > The striding and sub-offsets, however, allow extension module writers to > write code (say video and image processing code or scientific computing > code or data-base processing code) that works on any object exposing the > buffer interface. I think this will be of great benefit and so is worth > the complexity. > > This will take some work to get implemented for Python 3k. I could use > some help with this in order to speed up the process. I'm working right > now on the extensions to the struct module until the rest is approved. > > Thank you for any and all comments: > > -Travis ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] minidom and DOM level 2
On 4/7/07, Andrew Clover <[EMAIL PROTECTED]> wrote: > Jason Orendorff wrote: > > OK, I think this is worthwhile then. :) I'll read the spec and submit > > a patch. > > You're planning to implement EntityReference in minidom? That'll be fun! > :-) One of the nastier corners of DOM and XML in general. Mmm. So I'm finding. EntityReferences seem to force detailed knowledge of entity handling into the DOM implementation. expat doesn't expose the information in a particularly helpful way. In a word, blaargh. I'd be happy to set this aside and work on Level 1 compliance: > Incidentally minidom falls far short of passing even Level 1 Core for > more reasons than omission of EntityReference. I noted the main known > problems with it here: >http://pyxml.sourceforge.net/topics/compliance.html Very nice. Thanks for posting this. I don't suppose you'd be willing to update it for Python 2.5, would you? Martin, have you looked at this? Some of these might be hard to fix, given expat. -j ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] function for counting items in a sequence
Alex Martelli wrote: > Steven Bethard <[EMAIL PROTECTED]> wrote: > >> Alex Martelli wrote: >> > If we had a "turn sequence into bag" function somewhere >> > (and it might be worth having it for other reasons): >> > >> > def bagit(seq): >> > import collections >> > d = collections.defaultdict(int) >> > for x in seq: d[x] += 1 >> > return d >> >> I use this function all the time -- I call it dicttools.count(). I'd >> love to see this appear in the collections module or somewhere else in >> the stdlib. > > Maybe you should propose it in python-dev -- it does seem a reasonable > utility addition to the collections module, after all. Here's a patch implementing collections.counts() as suggested above: http://bugs.python.org/1696199 Example usage, from the docstring:: >>> items = 'acabbacba' >>> item_counts = counts(items) >>> for item in 'abcd': ... print item, item_counts[item] ... a 4 b 3 c 2 d 0 The documentation is a little terse, but the function was so simple, I wasn't really sure what more to say. STeVe ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] minidom and DOM level 2
> Martin, have you looked at this? Only just now. I assume Andrew is right on these, although one would have to verify each and every one, reading the spec, reading the documentation, reading the source, testing, fixing. Very time-consuming. In any case, the *claim* certainly is that minidom supports level 2 core. Any proof to the contrary indicates a bug; patches are welcome. Regards, Martin ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] minidom and DOM level 2
On 4/7/07, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote: > In any case, the *claim* certainly is that minidom supports > level 2 core. Any proof to the contrary indicates a bug; > patches are welcome. OK-- I'll work on this. I can fix the easy ones, anyway. -j ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
[Python-Dev] Summary of Tracker Issues
ACTIVITY SUMMARY (04/01/07 - 04/08/07) Tracker at http://bugs.python.org/ To view or respond to any of the issues listed below, click on the issue number. Do NOT respond to this message. 1647 open ( +0) / 8584 closed ( +0) / 10231 total ( +0) Average duration of open issues: 758 days. Median duration of open issues: 707 days. Open Issues Breakdown open 1647 ( +0) pending 0 ( +0) ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] function for counting items in a sequence
On 4/7/07, Steven Bethard <[EMAIL PROTECTED]> wrote: > Here's a patch implementing collections.counts() as suggested above: > > http://bugs.python.org/1696199 > > Example usage, from the docstring:: > > >>> items = 'acabbacba' > >>> item_counts = counts(items) > >>> for item in 'abcd': > ... print item, item_counts[item] > ... > a 4 > b 3 > c 2 > d 0 Guido commented in the tracker that it would be worth discussing whether that last item (``item_counts['d']``) should return 0 (as a defaultdict would) or raise KeyError (as a dict would). Anyone have a good motivation for one approach or the other? STeVe -- I'm not *in*-sane. Indeed, I am so far *out* of sane that you appear a tiny blip on the distant coast of sanity. --- Bucky Katt, Get Fuzzy ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] function for counting items in a sequence
On 4/7/07, Steven Bethard <[EMAIL PROTECTED]> wrote: > Here's a patch implementing collections.counts() as suggested above: The name doesn't make it obvious to me what's going on. Maybe countunique()? Some other options are countdistinct() and countduplicates(). > >>> items = 'acabbacba' > >>> item_counts = counts(items) > >>> for item in 'abcd': > ... print item, item_counts[item] > ... > a 4 > b 3 > c 2 > d 0 Would become: >>> items = 'acabbacba' >>> counts = countunique(items) >>> for item in 'abcd': ... print item, counts[item] ... a 4 b 3 c 2 d 0 -- Adam Olsen, aka Rhamphoryncus ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] function for counting items in a sequence
On 4/7/07, Steven Bethard <[EMAIL PROTECTED]> wrote: On 4/7/07, Steven Bethard <[EMAIL PROTECTED]> wrote: > Here's a patch implementing collections.counts() as suggested above: > > http://bugs.python.org/1696199 > > Example usage, from the docstring:: > > >>> items = 'acabbacba' > >>> item_counts = counts(items) > >>> for item in 'abcd': > ... print item, item_counts[item] > ... > a 4 > b 3 > c 2 > d 0 Guido commented in the tracker that it would be worth discussing whether that last item (``item_counts['d']``) should return 0 (as a defaultdict would) or raise KeyError (as a dict would). Anyone have a good motivation for one approach or the other? I say 0 if it is really meant to represent a count as the absense of something is 0. The object returned is being viewed as an object representing the count of items, not specifically as a dict. -Brett ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] function for counting items in a sequence
Steven Bethard wrote: > Guido commented in the tracker that it would be worth discussing > whether that last item (``item_counts['d']``) should return 0 (as a > defaultdict would) or raise KeyError (as a dict would). If you've asked for a count of 'd's, and there aren't any 'd's, the most sensible answer would seem to be 0, not an exception. Also it would be a useful property if you were guaranteed that all items in the input sequence are usable as keys in the result without causing an exception. -- Greg ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] function for counting items in a sequence
Adam Olsen wrote: > The name doesn't make it obvious to me what's going on. Maybe > countunique()? That doesn't sound any more obvious to me. counteach? countall? -- Greg ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] function for counting items in a sequence
On 4/7/07, Adam Olsen <[EMAIL PROTECTED]> wrote: > On 4/7/07, Steven Bethard <[EMAIL PROTECTED]> wrote: > > Here's a patch implementing collections.counts() as suggested above: > > The name doesn't make it obvious to me what's going on. Maybe > countunique()? Some other options are countdistinct() and > countduplicates(). -1. I like the name that Steve proposed just fine; "counts" perfectly explain that it produces counts of items. If there couldn't be duplicates then "counts" wouldn't make sense since the only outcomes would be True or False (present or not). -- --Guido van Rossum (home page: http://www.python.org/~guido/) ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
Re: [Python-Dev] function for counting items in a sequence
On 4/7/07, Guido van Rossum <[EMAIL PROTECTED]> wrote: On 4/7/07, Adam Olsen <[EMAIL PROTECTED]> wrote: > On 4/7/07, Steven Bethard <[EMAIL PROTECTED]> wrote: > > Here's a patch implementing collections.counts() as suggested above: > > The name doesn't make it obvious to me what's going on. Maybe > countunique()? Some other options are countdistinct() and > countduplicates(). -1. I like the name that Steve proposed just fine; "counts" perfectly explain that it produces counts of items. If there couldn't be duplicates then "counts" wouldn't make sense since the only outcomes would be True or False (present or not). I call that function 'tally'. -Kevin ___ Python-Dev mailing list [email protected] http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com
