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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:42:45+00:00 2026-05-17T23:42:45+00:00

I’m saving NumPy arrays using numpy.save function. I want other developers to have capability

  • 0

I’m saving NumPy arrays using numpy.save function.
I want other developers to have capability to read data from those file using C language.
So I need to know,how numpy organizes binary data in file.OK, it’s obvious when I’m saving array of ‘i4’ but what about array of arrays that contains some structures?Can’t find any info in documentation

UPD :
lets say tha data is something like :

dt = np.dtype([('outer','(3,)<i4'),('outer2',[('inner','(10,)<i4'),('inner2','f8')])])

UPD2 : What about saving “dynamic” data (dtype – object)

import numpy as np
a = [0,0,0]
b = [0,0]
c = [a,b]
dtype = np.dtype([('Name', '|S2'), ('objValue', object)])
data = np.zeros(3, dtype)
data[0]['objValue'] = a
data[1]['objValue'] = b
data[2]['objValue'] = c
data[0]['Name'] = 'a'
data[1]['Name'] = 'b'
data[2]['Name'] = 'c'

np.save(r'D:\in.npy', data)

Is it real to read that thing from C?

  • 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-05-17T23:42:45+00:00Added an answer on May 17, 2026 at 11:42 pm

    The npy file format is documented in numpy’s NEP 1 — A Simple File Format for NumPy Arrays.

    For instance, the code

    >>> dt=numpy.dtype([('outer','(3,)<i4'),
    ...                 ('outer2',[('inner','(10,)<i4'),('inner2','f8')])])
    >>> a=numpy.array([((1,2,3),((10,11,12,13,14,15,16,17,18,19),3.14)),
    ...                ((4,5,6),((-1,-2,-3,-4,-5,-6,-7,-8,-9,-20),6.28))],dt)
    >>> numpy.save('1.npy', a)
    

    results in the file:

    93 4E 55 4D 50 59                      magic ("\x93NUMPY")
    01                                     major version (1)
    00                                     minor version (0)
    
    96 00                                  HEADER_LEN (0x0096 = 150)
    7B 27 64 65 73 63 72 27 
    3A 20 5B 28 27 6F 75 74 
    65 72 27 2C 20 27 3C 69 
    34 27 2C 20 28 33 2C 29 
    29 2C 20 28 27 6F 75 74 
    65 72 32 27 2C 20 5B 28 
    27 69 6E 6E 65 72 27 2C 
    20 27 3C 69 34 27 2C 20 
    28 31 30 2C 29 29 2C 20 
    28 27 69 6E 6E 65 72 32                Header, describing the data structure
    27 2C 20 27 3C 66 38 27                "{'descr': [('outer', '<i4', (3,)),
    29 5D 29 5D 2C 20 27 66                            ('outer2', [
    6F 72 74 72 61 6E 5F 6F                               ('inner', '<i4', (10,)), 
    72 64 65 72 27 3A 20 46                               ('inner2', '<f8')]
    61 6C 73 65 2C 20 27 73                            )],
    68 61 70 65 27 3A 20 28                  'fortran_order': False,
    32 2C 29 2C 20 7D 20 20                  'shape': (2,), }"
    20 20 20 20 20 20 20 20 
    20 20 20 20 20 0A 
    
    01 00 00 00 02 00 00 00 03 00 00 00    (1,2,3)
    0A 00 00 00 0B 00 00 00 0C 00 00 00
    0D 00 00 00 0E 00 00 00 0F 00 00 00
    10 00 00 00 11 00 00 00 12 00 00 00
    13 00 00 00                            (10,11,12,13,14,15,16,17,18,19)
    1F 85 EB 51 B8 1E 09 40                3.14
    
    04 00 00 00 05 00 00 00 06 00 00 00    (4,5,6)
    FF FF FF FF FE FF FF FF FD FF FF FF
    FC FF FF FF FB FF FF FF FA FF FF FF
    F9 FF FF FF F8 FF FF FF F7 FF FF FF 
    EC FF FF FF                            (-1,-2,-3,-4,-5,-6,-7,-8,-9,-20)
    1F 85 EB 51 B8 1E 19 40                6.28
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a bunch of posts stored in text files formatted in yaml/textile (from
I have some data like this: 1 2 3 4 5 9 2 6
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker

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.