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

  • SEARCH
  • Home
  • 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 8567709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T17:56:37+00:00 2026-06-11T17:56:37+00:00

Is it possible to tell pyparsing to not store ParseResults or manually discard them?

  • 0

Is it possible to tell pyparsing to not store ParseResults or manually discard them?

I’m parsing a large file of items and can do all the post-processing for each item via a parse action. So as soon as an item has been parsed I don’t need it’s ParseResult any more and would like to be able to discard it as I’m hitting the memory limit of the machine I’m on.

  • 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-06-11T17:56:38+00:00Added an answer on June 11, 2026 at 5:56 pm

    Are you using parse actions to process the tokens as they are parsed? If so, you can delete the contents of the parsed tokens using del:

    def parseActionThatDeletesTheParsedTokens(tokens):
        # ...
        # do something interesting with the tokens
        # ...
    
        # delete the contents of the parsed tokens
        del tokens[:]
    

    Or you might want to just use scanString instead of parseString. Instead of this:

    OneOrMore(blockOfText).parseString(bigHonkingString)
    

    do:

    for tokens, matchstart, matchend in blockOfText.scanString(bigHonkingString):
        # do stuff with the tokens
    

    scanString returns a generator which yields 3-tuples containing the matched tokens, the starting, and ending location of each successive match. You can process each parsed set of tokens, then when you move on to the next set, the old set is automatically discarded. I think this may be the simplest way for you to go, with minimal changes to your program.

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

Sidebar

Related Questions

I understand that it is not possible to tell what the user is doing
Possible Duplicate: How to tell if a list is infinite? In Haskell, you can
Tell me please is it possible to break the process of parsing? I.e. exit
Is it possible to tell the C preprocessor to check whether a function (not
It's possible to tell GCC it should not use padding for the struct. This
Is it possible to in some way tell the maven deploy:file goal to deploy
Is it possible to tell phpunit where to put generated test skeleton file by
Is it possible to tell JPanel to set its size to fit all components
Is it possible to tell jqGrid to send all search options in JSON format
Possible Duplicates: Fast CSV parsing How to properly parse CSV file to 2d Array?

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.