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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:28:11+00:00 2026-06-18T11:28:11+00:00

I would like to manually write out what itertools does in one line so

  • 0

I would like to manually write out what itertools does in one line so that I can attempt to use multiple strings to work through the function quicker. Right now this function works, I just need to massively speed it up. I am not really even sure if writing out the itertools line would enable me to use multiple threads.

def list ():
charLength = sys.argv[2]
charSet = 'abcdefghijklmnopqrstuvwxyz0123456789'

combo = itertools.combinations_with_replacement(charSet, int(charLength))
for floatingcombo in combo:
    floatingcombo = ''.join(floatingcombo)
    floatingcombo += "." + sys.argv[3]
    try:
        floatingIP = socket.gethostbyname(floatingcombo)
        msvcrt.printf("%s resolved to --> %s\n", floatingcombo, floatingIP)
    except socket.gaierror:
        msvcrt.printf("%s does not exist\n", floatingcombo)
return
  • 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-18T11:28:13+00:00Added an answer on June 18, 2026 at 11:28 am

    Your problem is probably IO-bound. You could speed up the lookup by using multiple threads/processes. To avoid threading issues in dns implementation, you could use multiple processes to resolve hosts:

    #!/usr/bin/env python
    import itertools
    import socket
    import sys
    from functools import partial
    from multiprocessing import Pool
    
    def resolve(host, domain=""):
        host = ''.join(host) + domain
        try:
            return host, socket.gethostbyname(host), None
        except EnvironmentError as e:
            return host, None, e
    
    def main():
        alphabet = 'abcdefghijklmnopqrstuvwxyz0123456789'
        size = int(sys.argv[2])
        resolve_host = partial(resolve, domain="." + sys.argv[3])
        combo = itertools.combinations_with_replacement(alphabet, size)
    
        pool = Pool(20) 
        for host, ip, error in pool.imap_unordered(resolve_host, combo):
            if error is None:
               print("%s resolved to --> %s" % (host, ip))
            else: # error
               print("Can't resolve %s, error: %s" % (host, error))
    
    if __name__=="__main__":
       main()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to use substitution in Vim to do unindentation manually (instead of
I would like to write a script that logs into hotmail and changes the
How can I mannually terminate an excel application using OLE Automation? I would like
Would like a for loop in jquery so that: For every hover_link: show hidden
Would like to make anapplication in Java that will not automatically parse parameters used
I would like to know how to write up the vbs code to schedule
I would like to read a file into a script, line by line. Each
I have a relatively simple DSL that I would like to handle more robustly
Would like to parse IPv4 address from exit-addresses . Format of the file: ExitNode
Would like someone to take a look at my script and tell me where

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.