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 8924951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:33:53+00:00 2026-06-15T07:33:53+00:00

I’m trying to make a simple intermediate compilation function: lst = [lambda x: calculate_urls(),

  • 0

I’m trying to make a simple intermediate compilation function:

lst = [lambda x: calculate_urls(),
       lambda x: join_urls_with_ids(x, args[0]),
       lambda x: bucket_urls(x)]
intermediate.execute(lst)

intermediate.execute will run each item in the list. The first function’s output is the second function’s input, and so on. The lambdas are used to make each function take only one argument. (The first input value is None, so it’s effectively ignored here.)

At each intermediate step the output is pickled and saved (currently just to /tmp). If some intermediate output already exists for a function, execution of the function is skipped and it goes onto the next step.

I’m looking for a way to detect changes in the function code, and I figured hashing the code would be a quick way of doing that. I want it to detect if someone changed the implementation of a function, so that it would execute the function again and ignore the cached value.

I found out about func_code, which is hashable AFAIK. However, it only works for that particular function, which means that the hash only changes if the lambdas in the code above change, not the functions being called by the lambdas. Is what I’m looking for theoretically possible? Is there a reasonable middle ground?

  • 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-15T07:33:55+00:00Added an answer on June 15, 2026 at 7:33 am

    Instead of storing lambdas, you could store lists of function-argument tuples, and hash the func_code of those functions. That is, instead of what you have, do:

    lst = [
        (calculate urls, ()),
        (join_urls_with_ids, (args[0])),
        (bucket_urls, ())
    ]
    

    Then make intermediate.execute be like:

    def execute(lst):
        result = ()
        for func, args in list:
            args = result + args
            result = func(*args)
    

    However, it’s a little hard to grasp what you’re trying to do here. Is the idea that the function implementations might change between different invocations of the program? (That is, run, save cache, exit, change the source code of calculate_urls, then run again?) If so, you might be better off hashing the function’s source code instead (using inspect.getsource). Python bytecode (which is what’s in func_code) is not really a stable target and could change between Python versions.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I need a function that will clean a strings' special characters. I do NOT
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am trying to render a haml file in a javascript response like so:
I am doing a simple coin flipping experiment for class that involves flipping a

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.