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 8338101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T04:29:27+00:00 2026-06-09T04:29:27+00:00

I have an array of float values that is created in regular Python, that

  • 0

I have an array of float values that is created in regular Python, that I want to pass to a cython function that fronts for an underlying C function.
The C function requires the array to be passed as a floating pointer as in:

void setOverlays(const float * verts);

the cython wrapper looks like this:

def set_overlays(verts):
    setOverlays(verts)

How can I make verts into a cython array?
I thought that this might work:

cdef float * cVerts = [v for v in verts]

but unfortunately the value generated is a Python object and in this case automatic conversion does not work.

The equivalent expression(that works) in ctypes is:

cVerts = (c_float * len(verts))()
for i in range(len(verts)):
    cVerts[i] = verts[i]
setOverlays(cast(byteref(cVerts), POINTER(c_float)))

I am trying to achieve the same thing, but in cython

Thanks in advance!

  • 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-09T04:29:28+00:00Added an answer on June 9, 2026 at 4:29 am

    I found the Cython specific way:

    cdef float* cVerts = []
        for i in xrange(len(verts)):
            cVerts[i] = verts[i]
    setOverlays(cVerts)
    

    Interestingly enough the above two solutions were rejected by the cython compiler.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi i have created a Generic Array that works fine for Int,String, Float or
I have a Java array defined already e.g. float[] values = new float[3]; I
Lets say that i have the following array : float QuadVertices[4 * 2]; float
I have some Thread count pCount and I have some float[] array. I want
I'm attempting to create a function where I can pass names and values that
I want a function that creates an array of increasing floats. I run into
I have an array of float that I need to send over TCP/IP, the
I have two dimensional float array as below {0.2,0.0,0.3,0.0,0.0} {0.4,0.1,0.0,0.0,0.9} {0.0,0.0,0.0,0.3,0.6} I want to
If I have this float array declaration: float tables[10]; How can I change the
I have an int and float array of length 220 million (fixed). Now, I

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.