Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #102199 > unrolled thread

psss...I want to move from Perl to Python

Started byFillmore <fillmore_remove@hotmail.com>
First post2016-01-28 19:01 -0500
Last post2016-02-02 19:36 -0500
Articles 20 on this page of 74 — 27 participants

Back to article view | Back to comp.lang.python


Contents

  psss...I want to move from Perl to Python Fillmore <fillmore_remove@hotmail.com> - 2016-01-28 19:01 -0500
    Re: psss...I want to move from Perl to Python paul.hermeneutic@gmail.com - 2016-01-28 17:22 -0700
    Re: psss...I want to move from Perl to Python Nathan Hilterbrand <nhilterbrand@gmail.com> - 2016-01-28 19:21 -0500
      Re: psss...I want to move from Perl to Python Rick Johnson <rantingrickjohnson@gmail.com> - 2016-01-28 19:23 -0800
        Re: psss...I want to move from Perl to Python Chris Angelico <rosuav@gmail.com> - 2016-01-29 14:26 +1100
      Re: psss...I want to move from Perl to Python wxjmfauth@gmail.com - 2016-01-30 02:26 -0800
        Re: psss...I want to move from Perl to Python Fillmore <fillmore_remove@hotmail.com> - 2016-01-31 17:34 -0500
          Re: psss...I want to move from Perl to Python Michael Torrie <torriem@gmail.com> - 2016-01-31 16:45 -0700
          Re: psss...I want to move from Perl to Python Chris Angelico <rosuav@gmail.com> - 2016-02-01 10:48 +1100
          Re: psss...I want to move from Perl to Python Terry Reedy <tjreedy@udel.edu> - 2016-01-31 18:51 -0500
            Re: psss...I want to move from Perl to Python Rustom Mody <rustompmody@gmail.com> - 2016-01-31 18:59 -0800
              Re: psss...I want to move from Perl to Python Chris Angelico <rosuav@gmail.com> - 2016-02-01 14:15 +1100
                Re: psss...I want to move from Perl to Python Rustom Mody <rustompmody@gmail.com> - 2016-01-31 19:43 -0800
                Re: psss...I want to move from Perl to Python Rick Johnson <rantingrickjohnson@gmail.com> - 2016-02-02 14:53 -0800
    Re: psss...I want to move from Perl to Python Chris Angelico <rosuav@gmail.com> - 2016-01-29 11:25 +1100
      Re: psss...I want to move from Perl to Python Steven D'Aprano <steve@pearwood.info> - 2016-01-29 18:12 +1100
        Re: psss...I want to move from Perl to Python Chris Angelico <rosuav@gmail.com> - 2016-01-29 18:19 +1100
        Re: psss...I want to move from Perl to Python Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-01-29 09:12 +0000
          Re: psss...I want to move from Perl to Python James Harris <james.harris.1@gmail.com> - 2016-01-29 11:03 +0000
            Re: psss...I want to move from Perl to Python Ulli Horlacher <framstag@rus.uni-stuttgart.de> - 2016-01-29 12:21 +0000
              Re: psss...I want to move from Perl to Python Steven D'Aprano <steve@pearwood.info> - 2016-01-30 00:46 +1100
                Re: psss...I want to move from Perl to Python Ben Finney <ben+python@benfinney.id.au> - 2016-01-30 09:47 +1100
                  Re: psss...I want to move from Perl to Python Steven D'Aprano <steve@pearwood.info> - 2016-01-30 22:12 +1100
              Re: psss...I want to move from Perl to Python Rick Johnson <rantingrickjohnson@gmail.com> - 2016-01-29 13:30 -0800
                Re: psss...I want to move from Perl to Python Fillmore <fillmore_remove@hotmail.com> - 2016-01-29 19:57 -0500
                  Re: psss...I want to move from Perl to Python Ben Finney <ben+python@benfinney.id.au> - 2016-01-30 12:04 +1100
                Re: psss...I want to move from Perl to Python Rustom Mody <rustompmody@gmail.com> - 2016-01-29 19:38 -0800
                  Re: psss...I want to move from Perl to Python Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-01-31 11:18 +1300
                    Re: psss...I want to move from Perl to Python Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-01-31 12:56 +1100
                      Re: psss...I want to move from Perl to Python Rustom Mody <rustompmody@gmail.com> - 2016-01-30 19:22 -0800
                        Re: psss...I want to move from Perl to Python Cameron Simpson <cs@zip.com.au> - 2016-01-31 14:48 +1100
                          Re: psss...I want to move from Perl to Python Rustom Mody <rustompmody@gmail.com> - 2016-01-30 19:53 -0800
                            Re: psss...I want to move from Perl to Python Cameron Simpson <cs@zip.com.au> - 2016-01-31 20:56 +1100
                            Re: psss...I want to move from Perl to Python Paul Rubin <no.email@nospam.invalid> - 2016-01-31 09:45 -0800
                              Re: psss...I want to move from Perl to Python Rustom Mody <rustompmody@gmail.com> - 2016-01-31 18:08 -0800
                          Re: psss...I want to move from Perl to Python Steven D'Aprano <steve@pearwood.info> - 2016-01-31 20:23 +1100
                            Re: psss...I want to move from Perl to Python Cameron Simpson <cs@zip.com.au> - 2016-01-31 20:53 +1100
                              Re: psss...I want to move from Perl to Python Paul Rubin <no.email@nospam.invalid> - 2016-01-31 09:49 -0800
                                Re: psss...I want to move from Perl to Python Cameron Simpson <cs@zip.com.au> - 2016-02-01 08:16 +1100
                        Re: psss...I want to move from Perl to Python Terry Reedy <tjreedy@udel.edu> - 2016-01-31 07:28 -0500
                          Re: psss...I want to move from Perl to Python Rustom Mody <rustompmody@gmail.com> - 2016-01-31 05:12 -0800
                  Re: psss...I want to move from Perl to Python Rick Johnson <rantingrickjohnson@gmail.com> - 2016-01-30 14:25 -0800
                Re: psss...I want to move from Perl to Python Rustom Mody <rustompmody@gmail.com> - 2016-01-29 20:04 -0800
          Re: psss...I want to move from Perl to Python Random832 <random832@fastmail.com> - 2016-01-29 10:07 -0500
            Re: psss...I want to move from Perl to Python Fillmore <fillmore_remove@hotmail.com> - 2016-01-29 12:56 -0500
            Re: psss...I want to move from Perl to Python Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-01-30 11:21 +1300
          Re: psss...I want to move from Perl to Python sohcahtoa82@gmail.com - 2016-01-29 12:49 -0800
            Re: psss...I want to move from Perl to Python Rick Johnson <rantingrickjohnson@gmail.com> - 2016-01-29 14:29 -0800
        Re: psss...I want to move from Perl to Python Cameron Simpson <cs@zip.com.au> - 2016-01-30 10:48 +1100
    Re: psss...I want to move from Perl to Python Cameron Simpson <cs@zip.com.au> - 2016-01-29 12:20 +1100
    Re: psss...I want to move from Perl to Python Paul Rubin <no.email@nospam.invalid> - 2016-01-28 18:06 -0800
      Re: psss...I want to move from Perl to Python Chris Angelico <rosuav@gmail.com> - 2016-01-29 13:34 +1100
        Re: psss...I want to move from Perl to Python sohcahtoa82@gmail.com - 2016-01-29 12:41 -0800
          Re: psss...I want to move from Perl to Python Chris Angelico <rosuav@gmail.com> - 2016-01-30 07:54 +1100
          Re: psss...I want to move from Perl to Python Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-01-30 11:27 +1300
      Re: psss...I want to move from Perl to Python Michael Torrie <torriem@gmail.com> - 2016-01-28 21:42 -0700
      Re: psss...I want to move from Perl to Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-01-29 08:54 -0500
    Re: psss...I want to move from Perl to Python Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-01-29 08:24 +0200
    Re: psss...I want to move from Perl to Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-01-29 08:50 -0500
    Re: psss...I want to move from Perl to Python Fillmore <fillmore_remove@hotmail.com> - 2016-01-29 12:04 -0500
    Re: psss...I want to move from Perl to Python "Sven R. Kunze" <srkunze@mail.de> - 2016-01-29 18:39 +0100
    Re: psss...I want to move from Perl to Python Fillmore <fillmore_remove@hotmail.com> - 2016-01-29 15:42 -0500
      Re: psss...I want to move from Perl to Python Chris Angelico <rosuav@gmail.com> - 2016-01-30 07:51 +1100
      Re: psss...I want to move from Perl to Python Nathan Hilterbrand <nhilterbrand@gmail.com> - 2016-01-29 16:38 -0500
      Re: psss...I want to move from Perl to Python Cody Piersall <cody.piersall@gmail.com> - 2016-01-29 15:50 -0600
        Re: psss...I want to move from Perl to Python Josef Pktd <josef.pktd@gmail.com> - 2016-01-29 16:48 -0800
      Re: psss...I want to move from Perl to Python Terry Reedy <tjreedy@udel.edu> - 2016-01-29 22:08 -0500
      Re: psss...I want to move from Perl to Python Chris Angelico <rosuav@gmail.com> - 2016-01-30 14:12 +1100
    Re: psss...I want to move from Perl to Python Ben Finney <ben+python@benfinney.id.au> - 2016-01-30 09:49 +1100
    Re: psss...I want to move from Perl to Python Larry Hudson <orgnut@yahoo.com> - 2016-01-29 22:22 -0800
    Re: psss...I want to move from Perl to Python "Sven R. Kunze" <srkunze@mail.de> - 2016-01-30 13:43 +0100
    Re: psss...I want to move from Perl to Python <paul.hermeneutic@gmail.com> - 2016-02-02 10:00 -0700
    Re: psss...I want to move from Perl to Python "Martin A. Brown" <martin@linux-ip.net> - 2016-02-02 13:04 -0800
    Re: psss...I want to move from Perl to Python Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-02-02 19:36 -0500

Page 2 of 4 — ← Prev page 1 [2] 3 4  Next page →


#102230

FromSteven D'Aprano <steve@pearwood.info>
Date2016-01-30 00:46 +1100
Message-ID<56ab6d32$0$1612$c3e8da3$5496439d@news.astraweb.com>
In reply to#102227
On Fri, 29 Jan 2016 11:21 pm, Ulli Horlacher wrote:

> Most tutorials I found so far makes OO mandatory.


You should have started with the official tutorial:

https://docs.python.org/2/tutorial/


which doesn't get into classes until Chapter 9, after:

- using Python as a calculator;
- numbers, strings, unicode, lists;
- if, for, the range function;
- defining functions;
- stacks, queues;
- functional programming;
- list comprehensions;
- tuples, sets, dicts;
- modules;
- string formatting, reading and writing files, json; and
- exceptions

It's notable that *functional programming* is introduced before classes.



-- 
Steven

[toc] | [prev] | [next] | [standalone]


#102260

FromBen Finney <ben+python@benfinney.id.au>
Date2016-01-30 09:47 +1100
Message-ID<mailman.101.1454108110.2338.python-list@python.org>
In reply to#102230
Steven D'Aprano <steve@pearwood.info> writes:

> You should have started with the official tutorial:
>
> https://docs.python.org/2/tutorial/

And these days the default recommendation should be to start with the
official tutorial for the current stable version of the Python language,
Python 3 <URL:https://docs.python.org/3/tutorial/>.

-- 
 \       “We jealously reserve the right to be mistaken in our view of |
  `\      what exists, given that theories often change under pressure |
_o__)              from further investigation.” —Thomas W. Clark, 2009 |
Ben Finney

[toc] | [prev] | [next] | [standalone]


#102293

FromSteven D'Aprano <steve@pearwood.info>
Date2016-01-30 22:12 +1100
Message-ID<56ac9aaa$0$1611$c3e8da3$5496439d@news.astraweb.com>
In reply to#102260
On Sat, 30 Jan 2016 09:47 am, Ben Finney wrote:

> Steven D'Aprano <steve@pearwood.info> writes:
> 
>> You should have started with the official tutorial:
>>
>> https://docs.python.org/2/tutorial/
> 
> And these days the default recommendation should be to start with the
> official tutorial for the current stable version of the Python language,
> Python 3 <URL:https://docs.python.org/3/tutorial/>.


Python 2.7 is still a current stable version, and will be maintained until
at least 2020, after which you'll need commercial (paid) support from
vendors such as Red Hat if you want security updates.

I value your enthusiasm towards encouraging people to use Python 3, but
Python 2.7 is, for the time being, equally current and stable, and will be
for a few more years.

I can't remember why I gave the 2 tutorial instead of the 3 tutorial, but I
had a reason at the time... 

*wink*


-- 
Steven

[toc] | [prev] | [next] | [standalone]


#102250

FromRick Johnson <rantingrickjohnson@gmail.com>
Date2016-01-29 13:30 -0800
Message-ID<be09f9d4-ff7c-4e10-8188-1451e4657475@googlegroups.com>
In reply to#102227
On Friday, January 29, 2016 at 6:21:21 AM UTC-6, Ulli Horlacher wrote:
> I nearly gave up with Python at the very beginning before
> I realised that OO-programming is optional in Python! :-)
> Most tutorials I found so far makes OO mandatory.

Just more evidence that old dogs are incapable of learning
new tricks. Either learn how to wield Neuroplasticity to
your advantage, or go curl up into a ball and wait for death
to come. People who are unwilling to "expanding their
intellectual horizons" make me sick!!!

[toc] | [prev] | [next] | [standalone]


#102265

FromFillmore <fillmore_remove@hotmail.com>
Date2016-01-29 19:57 -0500
Message-ID<n8h1p5$qi2$1@gioia.aioe.org>
In reply to#102250
On 1/29/2016 4:30 PM, Rick Johnson wrote:
>  People who are unwilling to "expanding their
> intellectual horizons" make me sick!!!

did I miss something or is this aggressiveness unjustified?

[toc] | [prev] | [next] | [standalone]


#102266

FromBen Finney <ben+python@benfinney.id.au>
Date2016-01-30 12:04 +1100
Message-ID<mailman.105.1454115890.2338.python-list@python.org>
In reply to#102265
Fillmore <fillmore_remove@hotmail.com> writes:

> On 1/29/2016 4:30 PM, Rick Johnson wrote:
> >  People who are unwilling to "expanding their
> > intellectual horizons" make me sick!!!
>
> did I miss something or is this aggressiveness unjustified?

Indeed it is unjustified. The person to whom you respond is best ignored
(automatically, via a kill-file in your program). No matter how amusing
some trainwreck-chasers may find his outbursts, his unreasoning
hostility is disruptive.

-- 
 \         “What is it that makes a complete stranger dive into an icy |
  `\   river to save a solid gold baby? Maybe we'll never know.” —Jack |
_o__)                                                           Handey |
Ben Finney

[toc] | [prev] | [next] | [standalone]


#102273

FromRustom Mody <rustompmody@gmail.com>
Date2016-01-29 19:38 -0800
Message-ID<8d8e0774-0d25-443c-a466-6ab671bcaf3d@googlegroups.com>
In reply to#102250
On Saturday, January 30, 2016 at 3:01:09 AM UTC+5:30, Rick Johnson wrote:
> On Friday, January 29, 2016 at 6:21:21 AM UTC-6, Ulli Horlacher wrote:
> > I nearly gave up with Python at the very beginning before
> > I realised that OO-programming is optional in Python! :-)
> > Most tutorials I found so far makes OO mandatory.
> 
> Just more evidence that old dogs are incapable of learning
> new tricks. Either learn how to wield Neuroplasticity to
> your advantage, or go curl up into a ball and wait for death
> to come. People who are unwilling to "expanding their
> intellectual horizons" make me sick!!!

JFTR:
[Ranting] Rick is someone who I sometimes agree with were it not for the ranting style.

In this case I think its more important to rebut the contents of the rant than
the emotion-BS, especially given that one of the questions of the OP was re 're'.

Somebody said above that the re in python needs to be 'compiled' unlike perl.
Also if you see the docs they are mostly match/search orientated.

Both these are unnecessary OO-gook

1. One can use string-re's instead of compiled re's
2. One can use findall instead of search/match
3. One can do 
from re import findall
findall(...)

rather than

import re
re.findall(...)


1. By using string-res one need not create opaque re OBJECTS
2. By using findall one need not fish around in opaque match objects
3. By using from ... import one can reduce OO dotodotodotomania

In short python can be much less OO than is typically presented

[toc] | [prev] | [next] | [standalone]


#102319

FromGregory Ewing <greg.ewing@canterbury.ac.nz>
Date2016-01-31 11:18 +1300
Message-ID<dh4r6eFjbagU1@mid.individual.net>
In reply to#102273
Rustom Mody wrote:
> 1. One can use string-re's instead of compiled re's

And I gather that string REs are compiled on first use and
cached, so you don't lose much by using them most of the
time.

-- 
Greg

[toc] | [prev] | [next] | [standalone]


#102327

FromSteven D'Aprano <steve+comp.lang.python@pearwood.info>
Date2016-01-31 12:56 +1100
Message-ID<56ad69e4$0$14486$c3e8da3@news.astraweb.com>
In reply to#102319
On Sunday 31 January 2016 09:18, Gregory Ewing wrote:

> Rustom Mody wrote:
>> 1. One can use string-re's instead of compiled re's
> 
> And I gather that string REs are compiled on first use and
> cached, so you don't lose much by using them most of the
> time.

Correct. The re module keeps a cache of the last N regexes used, for some 
value of N (possibly 10?) so for casual use there's no real point to pre-
compiling other than fussiness.

But if you have an application that makes heavy-duty use of regexes, e.g. 
some sort of parser with dozens of distinct regexes, you might not want to 
rely on the cache.



-- 
Steve

[toc] | [prev] | [next] | [standalone]


#102328

FromRustom Mody <rustompmody@gmail.com>
Date2016-01-30 19:22 -0800
Message-ID<53d071aa-0f24-421b-8904-084071c4a8b2@googlegroups.com>
In reply to#102327
On Sunday, January 31, 2016 at 7:27:06 AM UTC+5:30, Steven D'Aprano wrote:
> On Sunday 31 January 2016 09:18, Gregory Ewing wrote:
> 
> > Rustom Mody wrote:
> >> 1. One can use string-re's instead of compiled re's
> > 
> > And I gather that string REs are compiled on first use and
> > cached, so you don't lose much by using them most of the
> > time.
> 
> Correct. The re module keeps a cache of the last N regexes used, for some 
> value of N (possibly 10?) so for casual use there's no real point to pre-
> compiling other than fussiness.
> 
> But if you have an application that makes heavy-duty use of regexes, e.g. 
> some sort of parser with dozens of distinct regexes, you might not want to 
> rely on the cache.
> 
> 
> 
> -- 
> Steve

Python 3.4.3+ (default, Oct 14 2015, 16:03:50) 
[GCC 5.2.1 20151010] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> python.el: native completion setup loaded
>>> 
>>> import re
>>> re._MAXCACHE
512
>>> 

Have you ever seen a program that uses 512 re's?
I havent :-)

[toc] | [prev] | [next] | [standalone]


#102330

FromCameron Simpson <cs@zip.com.au>
Date2016-01-31 14:48 +1100
Message-ID<mailman.150.1454212100.2338.python-list@python.org>
In reply to#102328
On 30Jan2016 19:22, rusi <rustompmody@gmail.com> wrote:
>Python 3.4.3+ (default, Oct 14 2015, 16:03:50)
>[GCC 5.2.1 20151010] on linux
>Type "help", "copyright", "credits" or "license" for more information.
>>>> python.el: native completion setup loaded
>>>>
>>>> import re
>>>> re._MAXCACHE
>512
>
>Have you ever seen a program that uses 512 re's?
>I havent :-)

I have. I've got one right here. It happens to be in perl, but it has been in 
need of a recode in Python for a long time. It has about 3000 regexps.

Of course they will be explicitly compiled in the recode.

Cheers,
Cameron Simpson <cs@zip.com.au>

[toc] | [prev] | [next] | [standalone]


#102331

FromRustom Mody <rustompmody@gmail.com>
Date2016-01-30 19:53 -0800
Message-ID<0a7a4070-f201-4eaa-aedb-80ab970ca06a@googlegroups.com>
In reply to#102330
On Sunday, January 31, 2016 at 9:18:31 AM UTC+5:30, Cameron Simpson wrote:
> On 30Jan2016 19:22, rusi wrote:
> >Python 3.4.3+ (default, Oct 14 2015, 16:03:50)
> >[GCC 5.2.1 20151010] on linux
> >Type "help", "copyright", "credits" or "license" for more information.
> >>>> python.el: native completion setup loaded
> >>>>
> >>>> import re
> >>>> re._MAXCACHE
> >512
> >
> >Have you ever seen a program that uses 512 re's?
> >I havent :-)
> 
> I have. I've got one right here. It happens to be in perl, but it has been in 
> need of a recode in Python for a long time. It has about 3000 regexps.
> 
> Of course they will be explicitly compiled in the recode.
> 

I would guess it needs more recoding than explicit compilation!
Maybe something like http://www.colm.net/open-source/ragel/
Unfortunately no python binding so far :-(

[toc] | [prev] | [next] | [standalone]


#102342

FromCameron Simpson <cs@zip.com.au>
Date2016-01-31 20:56 +1100
Message-ID<mailman.155.1454234217.2338.python-list@python.org>
In reply to#102331
On 30Jan2016 19:53, rusi <rustompmody@gmail.com> wrote:
>On Sunday, January 31, 2016 at 9:18:31 AM UTC+5:30, Cameron Simpson wrote:
>> On 30Jan2016 19:22, rusi wrote:
>> >Have you ever seen a program that uses 512 re's?
>> >I havent :-)
>>
>> I have. I've got one right here. It happens to be in perl, but it has been in
>> need of a recode in Python for a long time. It has about 3000 regexps.
>>
>> Of course they will be explicitly compiled in the recode.
>
>I would guess it needs more recoding than explicit compilation!
>Maybe something like http://www.colm.net/open-source/ragel/
>Unfortunately no python binding so far :-(

Interesting. Thanks,
Cameron Simpson <cs@zip.com.au>

[toc] | [prev] | [next] | [standalone]


#102362

FromPaul Rubin <no.email@nospam.invalid>
Date2016-01-31 09:45 -0800
Message-ID<87bn81r6bu.fsf@jester.gateway.pace.com>
In reply to#102331
Rustom Mody <rustompmody@gmail.com> writes:
> I would guess it needs more recoding than explicit compilation!
> Maybe something like http://www.colm.net/open-source/ragel/
> Unfortunately no python binding so far :-(

Neat, that looks kind of like lex/flex but with more backends.

[toc] | [prev] | [next] | [standalone]


#102381

FromRustom Mody <rustompmody@gmail.com>
Date2016-01-31 18:08 -0800
Message-ID<490b147c-08a5-4058-80b6-424fe84d1532@googlegroups.com>
In reply to#102362
On Sunday, January 31, 2016 at 11:15:50 PM UTC+5:30, Paul Rubin wrote:
> Rustom Mody  writes:
> > I would guess it needs more recoding than explicit compilation!
> > Maybe something like http://www.colm.net/open-source/ragel/
> > Unfortunately no python binding so far :-(
> 
> Neat, that looks kind of like lex/flex but with more backends.

Its much more than that. It freely allows mixing of the re and dfa paradigms.
Of course its a classic commonplace in CS that these two are isomorphic.
However structurally they are very different
Of course lex has a state management component as well -- I guess you can think
of ragel to lex in this respect as hll to assembly.

Also I believe its more efficient than lex

[toc] | [prev] | [next] | [standalone]


#102339

FromSteven D'Aprano <steve@pearwood.info>
Date2016-01-31 20:23 +1100
Message-ID<56add285$0$1593$c3e8da3$5496439d@news.astraweb.com>
In reply to#102330
On Sun, 31 Jan 2016 02:48 pm, Cameron Simpson wrote:

> I have. I've got one right here. It happens to be in perl, but it has been
> in need of a recode in Python for a long time. It has about 3000 regexps.

Wow. What's the code do?


-- 
Steven

[toc] | [prev] | [next] | [standalone]


#102341

FromCameron Simpson <cs@zip.com.au>
Date2016-01-31 20:53 +1100
Message-ID<mailman.154.1454234038.2338.python-list@python.org>
In reply to#102339
On 31Jan2016 20:23, Steven D'Aprano <steve@pearwood.info> wrote:
>On Sun, 31 Jan 2016 02:48 pm, Cameron Simpson wrote:
>> I have. I've got one right here. It happens to be in perl, but it has been
>> in need of a recode in Python for a long time. It has about 3000 regexps.
>
>Wow. What's the code do?

Adzapper. It has many many regexps matching URLs. (Actually a more globlike 
syntax, but it gets turned into a regexp.) You plug it into your squid proxy.

Cheers,
Cameron Simpson <cs@zip.com.au>

[toc] | [prev] | [next] | [standalone]


#102363

FromPaul Rubin <no.email@nospam.invalid>
Date2016-01-31 09:49 -0800
Message-ID<877fipr64m.fsf@jester.gateway.pace.com>
In reply to#102341
Cameron Simpson <cs@zip.com.au> writes:
> Adzapper. It has many many regexps matching URLs. (Actually a more
> globlike syntax, but it gets turned into a regexp.) You plug it into
> your squid proxy.

Oh cool, is that out there in circulation?

It sounds like the approach of merging all the regexes into one and
compiling to a FSM could be a big win.  I wouldn't expect too big a
state space explosion.

[toc] | [prev] | [next] | [standalone]


#102366

FromCameron Simpson <cs@zip.com.au>
Date2016-02-01 08:16 +1100
Message-ID<mailman.173.1454275011.2338.python-list@python.org>
In reply to#102363
On 31Jan2016 09:49, Paul Rubin <no.email@nospam.invalid> wrote:
>Cameron Simpson <cs@zip.com.au> writes:
>> Adzapper. It has many many regexps matching URLs. (Actually a more
>> globlike syntax, but it gets turned into a regexp.) You plug it into
>> your squid proxy.
>
>Oh cool, is that out there in circulation?

Yes:

  http://adzapper.sourceforge.net/

which includes the installation instructions (install script, add a line to 
squid.conf).

However my publication workflow is broken. (And source forge isn't what it used 
to be.) I need to get the update process improved. I'm happy to send the latest 
copy to people by private email.

>It sounds like the approach of merging all the regexes into one and
>compiling to a FSM could be a big win.  I wouldn't expect too big a
>state space explosion.

Perhaps so. The existing script (a) merges regexps for successive patterns for 
the same class and (b) use's perl's "study" function, which examines a string 
which will have several regexps applies to it - it nots things like character 
positions I gather, which is used in the matching process. Since the zapper 
applies all the rules to most URLs this is a performance win.

Cheers,
Cameron Simpson <cs@zip.com.au>

[toc] | [prev] | [next] | [standalone]


#102351

FromTerry Reedy <tjreedy@udel.edu>
Date2016-01-31 07:28 -0500
Message-ID<mailman.163.1454243349.2338.python-list@python.org>
In reply to#102328
On 1/30/2016 10:22 PM, Rustom Mody wrote:
> On Sunday, January 31, 2016 at 7:27:06 AM UTC+5:30, Steven D'Aprano wrote:
>> On Sunday 31 January 2016 09:18, Gregory Ewing wrote:

>> Correct. The re module keeps a cache of the last N regexes used, for some
>> value of N (possibly 10?) so for casual use there's no real point to pre-
>> compiling other than fussiness.
>>
>> But if you have an application that makes heavy-duty use of regexes, e.g.
>> some sort of parser with dozens of distinct regexes, you might not want to
>> rely on the cache.

>>>> import re
>>>> re._MAXCACHE
> 512
>>>>
>
> Have you ever seen a program that uses 512 re's?
> I havent :-)

I do not know if the cache was always there.  It used to be smaller, 
maybe 100, then 200.

-- 
Terry Jan Reedy

[toc] | [prev] | [next] | [standalone]


Page 2 of 4 — ← Prev page 1 [2] 3 4  Next page →

Back to top | Article view | comp.lang.python


csiph-web