Python Forum
Pyrex versus python - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Pyrex versus python (/thread-11746.html)

Pages: 1 2


Pyrex versus python - sylas - Jul-24-2018

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



RE: Pyrex versus python - nilamo - Jul-24-2018

Ok. What do you have so far?


RE: Pyrex versus python - sylas - Jul-25-2018

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


RE: Pyrex versus python - Larz60+ - Jul-25-2018

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,


RE: Pyrex versus python - nilamo - Jul-25-2018

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.


RE: Pyrex versus python - sylas - Jul-25-2018

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.


RE: Pyrex versus python - nilamo - Jul-25-2018

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


RE: Pyrex versus python - sylas - Jul-26-2018

I searched in ancient threads for prime numbers. I found many, but no one runs correctly. So I will continue to convert Pyrex file.


RE: Pyrex versus python - Larz60+ - Jul-26-2018

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 ?


RE: Pyrex versus python - sylas - Jul-26-2018

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.