Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7588009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:49:04+00:00 2026-05-30T19:49:04+00:00

From Perl’s documentation : study takes extra time to study SCALAR ($_ if unspecified)

  • 0

From Perl’s documentation:

study takes extra time to study SCALAR ($_ if unspecified) in anticipation of doing
many pattern matches on the string before it is next modified. This may or may not save
time, depending on the nature and number of patterns you are searching and the distribution
of character frequencies in the string to be searched;

I’m trying to speed up some regular expression-driven parsing that I’m doing in Python, and I remembered this trick from Perl. I realize I’ll have to benchmark to determine if there is a speedup, but I can’t find an equivalent method in Python.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T19:49:05+00:00Added an answer on May 30, 2026 at 7:49 pm

    As far as I know there’s nothing like this built into Python. But according to the perldoc:

    The way study works is this: a linked list of every character in the
    string to be searched is made, so we know, for example, where all the
    ‘k’ characters are. From each search string, the rarest character is
    selected, based on some static frequency tables constructed from some
    C programs and English text. Only those places that contain this
    “rarest” character are examined.

    This doesn’t sound very sophisticated, and you could probably hack together something equivalent yourself.

    esmre is kind of vaguely similar. And as @Frg noted, you’ll want to use re.compile if you’re reusing a single regex (to avoid re-parsing the regex itself over and over).

    Or you could use suffix trees (here’s one implementation, or here’s a C extension with unicode support) or suffix arrays (implementation).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been writing output from perl scripts to files for some time using code
I'm having trouble translating a subroutine from Perl to PHP (I'm new to Perl).
I want to convert a code from perl to c++, and my problem is
Is it possible to run an external process from Perl, capture its stderr, stdout
Is there any way to trap an error and exit gracefully from Perl? I
I'm in the processing of converting a program from Perl to Java. I have
I'm having a problem with executing a stored procedure from Perl (using the DBI
Coming from a Perl background, I have to say I prefer cpan Foo::Bar to
More information from the Perl 6 Wikipedia entry Junctions Perl 6 introduces the concept
When I installed perl from the source the first nice surprise was that without

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.