Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pyrex versus python
#1
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
Reply
#2
Ok. What do you have so far?
Reply
#3
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
Reply
#4
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,
Reply
#5
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.
Reply
#6
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.
Reply
#7
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
Reply
#8
I searched in ancient threads for prime numbers. I found many, but no one runs correctly. So I will continue to convert Pyrex file.
Reply
#9
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 ?
Reply
#10
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Determine if keyboard interrupt versus SIGINT trapped? Jibunnokage 5 1,807 Sep-30-2022, 06:54 AM
Last Post: Gribouillis
  Wsgiref versus Requisitions JohnnyCoffee 1 1,642 Jun-14-2020, 05:15 PM
Last Post: Larz60+
  Config file entry as list versus string? taziuk 2 1,834 Apr-25-2020, 12:01 PM
Last Post: ndc85430

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020