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

  • SEARCH
  • Home
  • 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 9285027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T19:03:18+00:00 2026-06-18T19:03:18+00:00

I want to know how to convert normal python list to C list with

  • 0

I want to know how to convert normal python list to C list with Cython , process it and return a python list. Like:

Python script:

import mymodule

a = [1,2,3,4,5,6]
len = len(a)
print(mymodule.process(a,len))

Cython script (mymodule.pyd):

cpdef process(a, int len):
    cdef float y
    for i in range(len):
        y = a[i]
        a[i] = y * 2
    return a

I read about MemoryView and many others things but I not really unterstand what happen and a lot of example use Numpy ( I don’t want to use it for avoid user of my script download a big package … anyway I think it’s don’t work with my software ). I need a really simple example to understand what’s happening exactly.

  • 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-18T19:03:19+00:00Added an answer on June 18, 2026 at 7:03 pm

    You’ll need to copy the contents of the list to an array explicitly. For example…

    cimport cython
    from libc.stdlib cimport malloc, free
    
    ...
    
    def process(a, int len):
    
        cdef int *my_ints
    
        my_ints = <int *>malloc(len(a)*cython.sizeof(int))
        if my_ints is NULL:
            raise MemoryError()
    
        for i in xrange(len(a)):
            my_ints[i] = a[i]
    
        with nogil:
            #Once you convert all of your Python types to C types, then you can release the GIL and do the real work
            ...
            free(my_ints)
    
        #convert back to python return type
        return value
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just want to know if there is a program that can convert an
want to know why String behaves like value type while using ==. String s1
I know C# and I want to convert this code into VB.NET. lol.Navigated +=
i want to know how to convert the time into 08:14PM 05 Jan 2013
I want to know how to convert big-endian numbers to native numbers in Delphi.
I want to know how to convert these kind of characters to their unicode
I want to know if it is safe/advisable to convert from ArrayList to Array?
I want to know if there is a function in C library that convert
I'd like to convert an existing table into the 1st normal form (simplest normalization
I want to know how can I convert and audio file store in the

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.