Python Forum

Full Version: Pyrex versus python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi all! I found a file in the language Pyrex and should like to transform it in python.
#Pyrex - a Language for Writing Python Extension Modules
#  Calculate prime numbers
#

def primes(int kmax):
  cdef int n, k, i
  cdef int p[1000]
  result = []
  if kmax > 1000:
    kmax = 1000
  k = 0
  n = 2
  while k < kmax:
    i = 0
    while i < k and n % p[i] <> 0:
      i = i + 1
    if i == k:
      p[k] = n
      k = k + 1
      result.append(n)
    n = n + 1
  return result
Ok. What do you have so far?
I know nothing about the language pyrex. It seems to be python and C++ melted. If here nobody knows about pyrex, I should like to have a file in python3 concerning prime numbers. Thanks
It looks like this package hasn't been worked on since 2010, and the last time migrated to PyPi is even older, uploaded Last: Apr 21, 2006. So tread lightly unless you can find more recent updates,
So what's your goal? You have pyrex code, but don't know what it does? It generates prime numbers, at most 1000, but it does so without recursion, and without any semblance of legibility.
I try every day to transform the Pyrex file in python3 file. It is not easy for me. Strange Larz60 cannot give me an example of a python3, prime numbers, since he has a lot of files. Maybe he is not allowed by the staff. If I had a file in python3 it would be easier for me to trasform the Pyrex file.
But why are you trying to convert it to python? There are hundreds of examples of prime numbers in python, there's really no reason to torture yourself trying to convert an example from a different language lol
I searched in ancient threads for prime numbers. I found many, but no one runs correctly. So I will continue to convert Pyrex file.
Quote:I searched in ancient threads for prime numbers. I found many, but no one runs correctly.
Oh really? did you look here: https://pypi.org/search/?q=prime ?
Now it is not a question of file, it is a question of package. Of course I uploaded the package. Things become more complex. Thanks to Larz.
Pages: 1 2