Re: [Zope-dev] ZTK 2.0: Deprecate zope.sequencesort
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 03/03/2013 10:34 PM, Arfrever Frehtes Taifersar Arahesis wrote: 2013-02-28 21:04:33 Tres Seaver napisa?(a): I have ported it to Python 3.2 and 3.3 and released a 4.0.0 version. There are still multiple problems (types.TupleType, sys.modules.has_key etc.): $ PYTHONPATH=src python3.3 -c import zope.sequencesort Traceback (most recent call last): File string, line 1, in module File /tmp/zope.sequencesort/src/zope/sequencesort/__init__.py, line 14, in module from zope.sequencesort.ssort import sort File /tmp/zope.sequencesort/src/zope/sequencesort/ssort.py, line 17, in module from types import TupleType ImportError: cannot import name TupleType Weird: the tests seemed to run, but only the 'coverage' section was actually running. I just released 4.0.1 which fixes the remaining test breakage under Py3k. Tres. - -- === Tres Seaver +1 540-429-0999 tsea...@palladion.com Palladion Software Excellence by Designhttp://palladion.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with undefined - http://www.enigmail.net/ iEYEARECAAYFAlE1DswACgkQ+gerLs4ltQ4kuwCffWRNVmRlWxJ1TEUOGMlFiRWV ZAUAoIcnx6EYG4EyiyxeNGmm7GWj+yFu =5NvX -END PGP SIGNATURE- ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZTK 2.0: Deprecate zope.sequencesort
2013-02-28 21:04:33 Tres Seaver napisał(a): I have ported it to Python 3.2 and 3.3 and released a 4.0.0 version. There are still multiple problems (types.TupleType, sys.modules.has_key etc.): $ PYTHONPATH=src python3.3 -c import zope.sequencesort Traceback (most recent call last): File string, line 1, in module File /tmp/zope.sequencesort/src/zope/sequencesort/__init__.py, line 14, in module from zope.sequencesort.ssort import sort File /tmp/zope.sequencesort/src/zope/sequencesort/ssort.py, line 17, in module from types import TupleType ImportError: cannot import name TupleType -- Arfrever Frehtes Taifersar Arahesis signature.asc Description: This is a digitally signed message part. ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZTK 2.0: Deprecate zope.sequencesort
On Fri, Mar 1, 2013 at 4:04 AM, Tres Seaver tsea...@palladion.com wrote: Assuming an unsorted list of news stories, how would you use sorted to get them ordered by category (ascending) + publication date (descending)? This is the easiest, most obvious way: sorted(sorted(news_stories, lambda x: x.publication_date, reverse=True), lambda x: x.category) And yes, I have made performance analysis, and it is often faster two do two sorts than trying to compute a complex key. If you spend more than a minute on it (e.g., trying to come up with a bug-free way to compute negative dates) you've proved my mpoint. :) I haven't got a clue what negative dates are, unless you mean BC. But the above works (unless I got ascending and descending mixed up as usual). //Lennart ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZTK 2.0: Deprecate zope.sequencesort
I'm sorry, it's early in the morning. It is of course: sorted(sorted(news_stories, key=lambda x: x.publication_date, reverse=True), key=lambda x: x.category) I forgot the key= bit. ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZTK 2.0: Deprecate zope.sequencesort
On Mar 1, 2013, at 19:06, Suresh V. suresh...@yahoo.com wrote: On Friday 01 March 2013 02:15 PM, Lennart Regebro wrote: I'm sorry, it's early in the morning. It is of course: sorted(sorted(news_stories, key=lambda x: x.publication_date, reverse=True), key=lambda x: x.category) Won't the two sorteds step over each other? No: since Python 2.2 sorting is guaranteed to be stable. See http://wiki.python.org/moin/HowTo/Sorting/#Sort_Stability_and_Complex_Sorts for more information. Wichert. ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZTK 2.0: Deprecate zope.sequencesort
Hi Tres, Am 28.02.2013, 21:04 Uhr, schrieb Tres Seaver tsea...@palladion.com: The main export of the package is the 'sort' function, which takes a sequence, per-column sort specs (key/attr name, sort function, direction), and optional extra data (e.g., the DTML namespace) and a flag indicating whether to use key or attribute lookup. The 'SortBy' class is really just an implementation detail of that API. I guess the right way to port the package is to implement a sort API. I have ported it to Python 3.2 and 3.3 and released a 4.0.0 version. Thanks for the port. I guess the question is still whether it should still be in ZTK - providing DTML as an example suggests that this really is a Zope only library. Do you see use for it outside the Zope context? Charlie -- Charlie Clark Managing Director Clark Consulting Research German Office Kronenstr. 27a Düsseldorf D- 40217 Tel: +49-211-600-3657 Mobile: +49-178-782-6226 ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZTK 2.0: Deprecate zope.sequencesort
On Fri, Mar 1, 2013 at 7:06 PM, Suresh V. suresh...@yahoo.com wrote: On Friday 01 March 2013 02:15 PM, Lennart Regebro wrote: I'm sorry, it's early in the morning. It is of course: sorted(sorted(news_stories, key=lambda x: x.publication_date, reverse=True), key=lambda x: x.category) Won't the two sorteds step over each other? Nope. Timsort is a stable sort, so you get a list that is sorted first by category and then by publication_date. //Lennart ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZTK 2.0: Deprecate zope.sequencesort
On Thursday, February 28, 2013, Stephan Richter wrote: I would like to deprecate zope.sequencesort in ZTK 2.0, since it cannot properly ported to Python 3, since it depends heavily on the cmp() way of sorting. I am also not a user of the package and I only tried to port the package for completeness sake. You can always fall back to functools.cmp_to_key() to use cmp-based sorting in python 3: http://docs.python.org/3/library/functools.html#functools.cmp_to_key -- Martijn Pieters -- Martijn Pieters ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
[Zope-dev] ZTK 2.0: Deprecate zope.sequencesort
Hi everyone, I would like to deprecate zope.sequencesort in ZTK 2.0, since it cannot properly ported to Python 3, since it depends heavily on the cmp() way of sorting. I am also not a user of the package and I only tried to port the package for completeness sake. Thoughts? Regards, Stephan -- Entrepreneur and Software Geek Google me. Zope Stephan Richter ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZTK 2.0: Deprecate zope.sequencesort
On Thu, Feb 28, 2013 at 2:43 PM, Stephan Richter stephan.rich...@gmail.com wrote: I would like to deprecate zope.sequencesort in ZTK 2.0, since it cannot properly ported to Python 3, since it depends heavily on the cmp() way of sorting. I am also not a user of the package and I only tried to port the package for completeness sake. Thx for trying. I'd be fine to drop it from the ZTK - Zope depends on it, but that just means it falls under their responsibility to maintain it. I think Grok never used it - so it fails the two users rule. In the same way, I think we should remove RestrictedPython and zope.untrustedpython from the ZTK. Since those are also very much dependencies of Zope alone and porting is going to be a very challenging task. Hanno ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZTK 2.0: Deprecate zope.sequencesort
On Feb 28, 2013, at 14:43 , Stephan Richter stephan.rich...@gmail.com wrote: Hi everyone, I would like to deprecate zope.sequencesort in ZTK 2.0, since it cannot properly ported to Python 3, since it depends heavily on the cmp() way of sorting. I am also not a user of the package and I only tried to port the package for completeness sake. What does it do? I could not find a single line of documentation for it, which makes it likely very few people, if any, are using it. Wichert. ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZTK 2.0: Deprecate zope.sequencesort
On Thursday, February 28, 2013 02:59:33 PM Hanno Schlichting wrote: In the same way, I think we should remove RestrictedPython and zope.untrustedpython from the ZTK. Since those are also very much dependencies of Zope alone and porting is going to be a very challenging task. Well, it is useful for any project allowing end-users to code Python code. I know we do in our project's UI. So I would feel more comfortable in keeping it, but I would not stop a port of my project to Python 3 because of its absence. So maybe ZTK should not either. ;-) I personally do not feel comfortable enough to tackle this package myself though. Regards, Stephan -- Entrepreneur and Software Geek Google me. Zope Stephan Richter ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZTK 2.0: Deprecate zope.sequencesort
On Thu, Feb 28, 2013 at 3:00 PM, Wichert Akkerman wich...@wiggy.net wrote: On Feb 28, 2013, at 14:43 , Stephan Richter stephan.rich...@gmail.com wrote: Hi everyone, I would like to deprecate zope.sequencesort in ZTK 2.0, since it cannot properly ported to Python 3, since it depends heavily on the cmp() way of sorting. I am also not a user of the package and I only tried to port the package for completeness sake. What does it do? I could not find a single line of documentation for it, which makes it likely very few people, if any, are using it. Reading through the code, it seems to use a lot of code to provide quite basic sorting functionality. It feels like it's trying to fill the same role as sorted() does since Python 2.4. //Lennart ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZTK 2.0: Deprecate zope.sequencesort
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 02/28/2013 08:43 AM, Stephan Richter wrote: Hi everyone, I would like to deprecate zope.sequencesort in ZTK 2.0, since it cannot properly ported to Python 3, since it depends heavily on the cmp() way of sorting. I am also not a user of the package and I only tried to port the package for completeness sake. Thoughts? I'm generally in favor of shrinking the ZTK, but just for discussion's sake: emulating 'cmp' for objects which have rich comparison semantics isn't that difficult:: def _faux_cmp(lhs, rhs): return int(rhs lhs) - int(lhs rhs) Tres. - -- === Tres Seaver +1 540-429-0999 tsea...@palladion.com Palladion Software Excellence by Designhttp://palladion.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with undefined - http://www.enigmail.net/ iEYEARECAAYFAlEvhpoACgkQ+gerLs4ltQ54KACggufMQUYdhD1Y9pefcP0qvAEE oEMAoLwcOL9/gGtdsIUJ0YlMme85WGhZ =ayRa -END PGP SIGNATURE- ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZTK 2.0: Deprecate zope.sequencesort
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 02/28/2013 10:41 AM, Lennart Regebro wrote: Reading through the code, it seems to use a lot of code to provide quite basic sorting functionality. It feels like it's trying to fill the same role as sorted() does since Python 2.4. The other features (locale-aware sorting, sort different keys using different algorithms / directions) are not easy to emulate using 'sorted()' Tres. - -- === Tres Seaver +1 540-429-0999 tsea...@palladion.com Palladion Software Excellence by Designhttp://palladion.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with undefined - http://www.enigmail.net/ iEYEARECAAYFAlEvhtAACgkQ+gerLs4ltQ7PRACbBuZ7YPdTbm0zsqCExZYn/gM0 7cwAoNhy13Nd/Avf0NZ6b+ChqbrfY77E =pITz -END PGP SIGNATURE- ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZTK 2.0: Deprecate zope.sequencesort
On Thursday, February 28, 2013 11:32:26 AM Tres Seaver wrote: Thoughts? I'm generally in favor of shrinking the ZTK, but just for discussion's sake: emulating 'cmp' for objects which have rich comparison semantics isn't that difficult:: def _faux_cmp(lhs, rhs): return int(rhs lhs) - int(lhs rhs) Well, that is the obvious implementation of cmp(), but that's not the point of the package. The package provides a callable class that represents a cmp() function. The problem is that it is not just creating some keys and calls cmp() on it. I could not find out a way to create a single key. I guess the right way to port the package is to implement a sort API. Regards, Stephan -- Entrepreneur and Software Geek Google me. Zope Stephan Richter ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZTK 2.0: Deprecate zope.sequencesort
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 02/28/2013 01:04 PM, Stephan Richter wrote: On Thursday, February 28, 2013 11:32:26 AM Tres Seaver wrote: Thoughts? I'm generally in favor of shrinking the ZTK, but just for discussion's sake: emulating 'cmp' for objects which have rich comparison semantics isn't that difficult:: def _faux_cmp(lhs, rhs): return int(rhs lhs) - int(lhs rhs) Well, that is the obvious implementation of cmp(), but that's not the point of the package. The package provides a callable class that represents a cmp() function. The problem is that it is not just creating some keys and calls cmp() on it. I could not find out a way to create a single key. The main export of the package is the 'sort' function, which takes a sequence, per-column sort specs (key/attr name, sort function, direction), and optional extra data (e.g., the DTML namespace) and a flag indicating whether to use key or attribute lookup. The 'SortBy' class is really just an implementation detail of that API. I guess the right way to port the package is to implement a sort API. I have ported it to Python 3.2 and 3.3 and released a 4.0.0 version. Tres. - -- === Tres Seaver +1 540-429-0999 tsea...@palladion.com Palladion Software Excellence by Designhttp://palladion.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with undefined - http://www.enigmail.net/ iEYEARECAAYFAlEvuFEACgkQ+gerLs4ltQ7+0wCg1gdpKIzx1Q1lvS0xVWAhSRIM wPsAniwipqErV4yMTkRDr5GxBz6GJfzW =6SHn -END PGP SIGNATURE- ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZTK 2.0: Deprecate zope.sequencesort
On Thu, Feb 28, 2013 at 5:33 PM, Tres Seaver tsea...@palladion.com wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 02/28/2013 10:41 AM, Lennart Regebro wrote: Reading through the code, it seems to use a lot of code to provide quite basic sorting functionality. It feels like it's trying to fill the same role as sorted() does since Python 2.4. The other features (locale-aware sorting, sort different keys using different algorithms / directions) are not easy to emulate using 'sorted()' Locale aware sorting can be tricky, I'll have to look at that code again. Sorting different keys and directions are trivial with sorted(). I'm not sure what different algorithms mean, with sorted you implement a function that returns a sorting key, that sorting key is then used to sort. It should be possible to sort according to any algorithm that way. //Lennart ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )
Re: [Zope-dev] ZTK 2.0: Deprecate zope.sequencesort
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 02/28/2013 10:00 PM, Lennart Regebro wrote: On Thu, Feb 28, 2013 at 5:33 PM, Tres Seaver tsea...@palladion.com wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 02/28/2013 10:41 AM, Lennart Regebro wrote: Reading through the code, it seems to use a lot of code to provide quite basic sorting functionality. It feels like it's trying to fill the same role as sorted() does since Python 2.4. The other features (locale-aware sorting, sort different keys using different algorithms / directions) are not easy to emulate using 'sorted()' Locale aware sorting can be tricky, I'll have to look at that code again. Sorting different keys and directions are trivial with sorted(). I'm not sure what different algorithms mean, with sorted you implement a function that returns a sorting key, that sorting key is then used to sort. It should be possible to sort according to any algorithm that way. Assuming an unsorted list of news stories, how would you use sorted to get them ordered by category (ascending) + publication date (descending)? If you spend more than a minute on it (e.g., trying to come up with a bug-free way to compute negative dates) you've proved my mpoint. :) Tres. - -- === Tres Seaver +1 540-429-0999 tsea...@palladion.com Palladion Software Excellence by Designhttp://palladion.com -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with undefined - http://www.enigmail.net/ iEYEARECAAYFAlEwGqcACgkQ+gerLs4ltQ64PACgoDSWLIhu1EJqTu1zEanfgHlY oxAAoJkzmsOK28Rco13S+06YRyMVhZ8k =T8Or -END PGP SIGNATURE- ___ Zope-Dev maillist - Zope-Dev@zope.org https://mail.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - https://mail.zope.org/mailman/listinfo/zope-announce https://mail.zope.org/mailman/listinfo/zope )