Author Topic: Python & fast Instr()  (Read 2669 times)


  • Administrator
  • Member
  • ******
  • Posts: 7321
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Python & fast Instr()
« Reply #15 on: January 30, 2019, 02:00:40 AM »
> Hutch will be happy to see that even with 32GB of RAM, you can allocate only 1.5GB in a 32-bit process

I test with 64 gig of memory but with /LARGEADDRESSAWARE in 32 bit you should be able to allocate up to 2 gig and still have about 700 meg free. Depends on the video card.
hutch at movsd dot com    :biggrin:  :skrewy:


  • Member
  • **
  • Posts: 81
Re: Python & fast Instr()
« Reply #16 on: January 30, 2019, 03:53:57 AM »

I'm not sure why Python is mentioned or whether why you are trying to challenge Python, but anything in assembly will be monumentally faster.  The Python method is find('substring', start, finish).  In Ruby, it is include?, but Ruby has a bajillion versions all of them are syntactic sugar for the same thing...

A while back in a Data Structures class we had to implement string search algorithms, so I made one from scratch in Java, Ruby and Python, and tested them.  The preferred algorithm to search for a substring in an array of characters is some version of rabin-karp or knuth-pratt algorithms.  I believe that all languages use some form of these, optimized for the language platform.

I attached a file done in Ruby that is based on the rabin-karp, it can search any string and find the pattern and offset, and match it.

Anywho, I will add this to my list of scripts to make in assembly, this will be fun, since it requires a good random num generator, prime generator, regex parser, and hash generator.


  • Moderator
  • Member
  • *****
  • Posts: 10337
  • Assembler is fun ;-)
    • MasmBasic
Re: Python & fast Instr()
« Reply #17 on: January 30, 2019, 04:43:37 AM »
Python is slow. Except when it is fast.

We must keep separate the language (often slow) and its functions, which may have been coded in excellent assembly. Python, for example, has the fastest sort functions of all hi level languages.