tag:blogger.com,1999:blog-18508356.post1598803137041896794..comments2026-02-13T11:24:21.556-05:00Comments on Just a little Python: Five things I hate about PythonRick Copelandhttp://www.blogger.com/profile/11612114223288841087noreply@blogger.comBlogger12125tag:blogger.com,1999:blog-18508356.post-82335121343772732562012-01-17T15:38:16.730-05:002012-01-17T15:38:16.730-05:00Thanks for the comment! I have done a few things w...Thanks for the comment! I have done a few things with the parser and ast modules. Lots of stuff has changed since I wrote this (for instance, dict comprehensions now exist). Blocks would still be nice, but I&#39;ve discovered I don&#39;t really want macros all that badly (see other posts on this blog re: MetaPython).Rick Copelandhttps://www.blogger.com/profile/11612114223288841087noreply@blogger.comtag:blogger.com,1999:blog-18508356.post-73705497523616508792012-01-17T14:19:17.396-05:002012-01-17T14:19:17.396-05:00Have you looked at the parser / ast modules? Gives...Have you looked at the parser / ast modules? Gives you access to python parse trees. Might be what you&#39;re looking for.brandon lewishttps://www.blogger.com/profile/17046865031973847470noreply@blogger.comtag:blogger.com,1999:blog-18508356.post-43326196279982847572009-01-02T09:38:00.000-05:002009-01-02T09:38:00.000-05:00@anonymous:Thanks for the tip on Metalua! I will ...@anonymous:<BR/><BR/>Thanks for the tip on Metalua! I will definitely look into it.Rick Copelandhttps://www.blogger.com/profile/11612114223288841087noreply@blogger.comtag:blogger.com,1999:blog-18508356.post-18092657577812108602009-01-02T04:47:00.000-05:002009-01-02T04:47:00.000-05:00For DSL that can be created from an already workin...For DSL that can be created from an already working functional language. I would recommend to look at Metalua. It is essentially an extension to Lua that lets one create new Syntax constructs (or change the original ones) in Lua.<BR/><BR/>The way it works is that you give it a Lua source file as an input, and then it gives you the AST of that source file with powerfull Node matching functions. So that you can transform that source code either in place (into another LUa file) or into something different.<BR/>I used it to create Lua-based DSL and transform it into javascript. There is a mailing for metalua as well.<BR/>Some people use it introduce new operators or other syntactic constructs into Lua.<BR/><BR/><BR/>I kind of thought that Python decorators can be used for DSL, but I do not think they are meant for this task.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-18508356.post-28593353278802341642007-07-18T07:30:00.000-04:002007-07-18T07:30:00.000-04:00This comment has been removed by a blog administrator.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-18508356.post-23579978430300582892007-07-03T12:11:00.000-04:002007-07-03T12:11:00.000-04:00I'll throw my two cents in. It's not a gripe with ...I'll throw my two cents in. It's not a gripe with Python per se, but with its standard library: the datetime module is weak. I can't compare a datetime.datetime instance with a datetime.date instance without jumping through hoops, its arithmetic is weak, and in most ways it's vastly inferior to Egenix's mx.DateTime library. Yet software like Django uses it, which means I spend a lot of time converting values between it and mx.DateTime. Not fun. I hope they pitch the module for Python 3000 and roll mx in instead.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-18508356.post-79890111913848338142007-04-25T11:02:00.000-04:002007-04-25T11:02:00.000-04:00I just stumbled across your blog and find it very ...I just stumbled across your blog and find it very informative! I noticed the comment about writing HDL in Python. Are you familiar with MyHDL (http://myhdl.jandecaluwe.com/doku.php)?<BR/><BR/>I have had good success using MyHDL and Python as a verification language and for writing HDL. I am not familiar with the "block" structure but MyHDL uses generators to describe hardware blocks (oopps may have overloaded a term).Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-18508356.post-20370926009149106792007-04-01T00:06:00.000-04:002007-04-01T00:06:00.000-04:00Re: Ian BickingFirst off, (and way off topic), I r...Re: Ian Bicking<BR/><BR/>First off, (and way off topic), I really enjoyed your talks at PyCon on WSGI and Zdjango Gears. I can honestly say I have never laughed harder at any technical conference.<BR/><BR/>You may be right on tail call elimination being more trouble than it's worth. I've never hacked on the Python interpreter, so I'm not really in a position to judge. However, it does seem that Python has a substantial function call overhead (IIRC), and tail call elimination would seem to remove that overhead when the optimization could be applied. So I guess I don't know how this particular optimization could possibly slow things down. (Though again, I don't hack the interpreter source, so I can't say authoritatively).<BR/><BR/>And hopefully this post made clear that these 5 things are not particularly large obstacles to my use of Python. Just some evidence that I'm not a completely off-base fanboy. None of these things are show-stoppers for me (and I like a lot more about python than I hate).Rick Copelandhttps://www.blogger.com/profile/11612114223288841087noreply@blogger.comtag:blogger.com,1999:blog-18508356.post-82473835673119459212007-03-31T17:41:00.000-04:002007-03-31T17:41:00.000-04:00I think tail call elimination is more trouble than...I think tail call elimination is more trouble than its worth. It messes up tracebacks since scopes disappear in ways that will be mysterious to most programmers. You can avoid this, but then it's just a funny little optimization that avoids some recursion limits -- but not all limits, and not in a way most people will understand, and probably slowing things down as a result. Maybe as a -OO option or something it would be reasonable, otherwise it's kind of lame IMHO.Ian Bickinghttps://www.blogger.com/profile/10921115783730718101noreply@blogger.comtag:blogger.com,1999:blog-18508356.post-79833477827065923302007-03-31T13:46:00.000-04:002007-03-31T13:46:00.000-04:00You can definitely use Python to preprocess files ...You can definitely use Python to preprocess files of a different syntax, but that's not really what I was thinking of. What I'd like to to be able to create a domain-specific language for hardware design that really looks like Python. Something like:<BR/><BR/>defmodule mymod(s1, s2, s3):<BR/>&nbsp;myfor(unrolled=True) i in range(10):<BR/>... <BR/><BR/>With blocks, I'd then be able to use operator overloading and such to build up a parse tree which I could then synthesize into RTL. Without them, I <I>can</I> use Python as a macro language, but not much else. In fact, <A HREF="http://nedbatchelder.com/code/cog/" REL="nofollow">Cog</A> is a great tool by Ned Batchelder that can be used to give pretty much any language a Python pre-processor. I'd just like to go a bit beyond that.Rick Copelandhttps://www.blogger.com/profile/11612114223288841087noreply@blogger.comtag:blogger.com,1999:blog-18508356.post-75280988650352466462007-03-31T13:35:00.000-04:002007-03-31T13:35:00.000-04:00P.S. The thing I hate about Python is it not havin...P.S. The thing I hate about Python is it not having a constrained random generator a-la SystemVerilog or Specman-e or Vera.<BR/><BR/>- Paddy.Paddy3118https://www.blogger.com/profile/06899509753521482267noreply@blogger.comtag:blogger.com,1999:blog-18508356.post-77521507026993523182007-03-31T13:33:00.000-04:002007-03-31T13:33:00.000-04:00I too work with Hardware. ASIC & FPGA designs; Ver...I too work with Hardware. ASIC & FPGA designs; Verilog VHDL, Specman ...<BR/><BR/>Earlier this year I wrote a preprocessorfor those translate_off/translate_on comments used to remove source fro consideration by synthesizers in Python. I next went on to write a Verilog preprocessor to handle all the backtic macros of Verilog; `define `ifdef `reset `include etc. <BR/><BR/>I did both in Python without blocks so it ca be done.<BR/><BR/>- Paddy.Paddy3118https://www.blogger.com/profile/06899509753521482267noreply@blogger.com