From: Yuri T. <qar...@gm...> - 2008-10-28 08:13:08
|
I haven't had a chance to play with this, but in principle this looks reasonable. I suggest that you merge this into mainline and let's assume that this is our solution for now. I'll try to think a little more about it next week. No offense to Ben - his library looked great. But it probably does makes more sense to go with a more standard solution. Ben: if you think we are making a mistake here, please speak up. :) - yuri On Wed, Oct 22, 2008 at 9:01 PM, Waylan Limberg <wa...@gm...> wrote: > I just pushed a new branch "dj-odict" [1] that implements a working > OrderedDict. You should see the last 2 commits in that branch. The > first of the 2 was an incomplete (it works but there is more work to > do) implementation of voidspace's OrderedDict with a few additional > methods. However, as that implementation included a lot of features > we'll never need (like comparison operators), I switched to the much > simpler Django implementation and improved the added methods. I've > reimplemented the ``add`` and ``link`` methods and they work with the > ``_begin``, ``_end``, ``<key``, and ``>key`` syntax. While they are > not necessary, it does make the code in the extension shorter and to > the point. The tests in regression_tests.py cover the features we need > pretty well. I still need to write documentation, but that can wait > until I know we're going to go with this. > > I didn't do any real performance/memory usage testing, but the > regression_tests consistently run a little faster with more tests so > I'm thinking we have a minimal speed increase with this. > > Personally, I like it. > > As an aside, note the change in the tables.py extension in that last > commit. I had to do that to get the test to pass. Thing is, is was > passing with Treap and it shouldn't have been because Treap was > getting the order wrong (I think - I haven't actually checked this). I > know it was getting the order wrong on footnotes for sure, but that > ext doesn't have tests so it didn't show up. There are still some > other, unrelated problems with footnotes though, so they aren't > working right now (I think I broke them when I refactored the > processors/patterns this past weekend). But there wasn't much point in > working on that when things weren't in the right order so I did this > first. > > [1]: http://gitorious.org/projects/python-markdown/repos/mainline/logs/dj-odict > > On Wed, Oct 22, 2008 at 12:53 PM, Yuri Takhteyev <qar...@gm...> wrote: >>> Apparently Treap wasn't tested in Python 2.3 as the builtin function >>> ``sorted`` (as well as ``operator.itemgetter`` which sorted needs) are >>> not available until 2.4. We get errors on import. Can't even try >>> running the code. >> >> I did test it with 2.3, discovered that it wasn't working, but thought >> that this would be fixable, so this has been on my todo list. >> >>> Personally, I'd prefer dropping Treap for an OrderedDict. odict [1] >> >> We can definitely think about this. I'll have to read up on odict to >> see if it does everything that we need. Of top of my head, though, >> odict 1400 lines, too big to just include in our code, so we would >> have to worry about an extra dependency. But let's think about this. >> Perhaps we should look at more options too. >> >> - yuri >> >> -- >> http://sputnik.freewisdom.org/ >> > > > > -- > ---- > Waylan Limberg > wa...@gm... > -- http://sputnik.freewisdom.org/ |