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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:56:21+00:00 2026-06-04T22:56:21+00:00

I want to create a small NumPy integer to save memory. However, I noticed

  • 0

I want to create a small NumPy integer to save memory. However, I noticed that

import numpy,sys
print sys.getsizeof(numpy.int8(1))

prints 12, so it seems that numpy.int8() is generating 12 bytes instead of 1 byte of data. Why is this?

  • 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-04T22:56:22+00:00Added an answer on June 4, 2026 at 10:56 pm

    Numpy scalars have similar implementations to the CPython data types, such as the python float or integer types. In other words, it is a struct containing three variables:

    • A reference counter of type int

    • A pointer to an instance of its object type

    • The value of the variable

    The reference counter and the pointer would usually be 4 bytes each in 32-bit architectures. The value field could be any size in principle, but structure padding will cause the struct to allocate 4 bytes, even if value requires less.

    If you are working on a 64-bit architecture, replace “4 bytes” with “8 bytes”.

    So, all numpy integers on a 32-bit system consist of (effectively) three 4-byte variables, and sys.getsizeof(numpy.int8(1)) gives 12. On a 64-bit system, it would return 24.

    Most numpy scalars are the same size. One exception is the numpy.complex type, which generally requires double storage. Since this aligns in memory with the other two variables, you can ignore padding and simply double the bytes allocated for the value, giving 16 and 32 bytes in 32- and 64-bit, respectively. Similar rules apply to the more exotic types (complex256, float80, etc.)

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

Sidebar

Related Questions

I want to create a small helpdesk ticket control system at work, that would
I want to create a small program in C# in Windows that would open
I want to create a small delay so that my 1st set of codes
I want to create a small sample app that can read my employee badge
I want to create a layout that has small panels at the top and
I want to create a small application that will be able to recognize sound.
I want to create a small Java application that will be capable of simple
i want to create functions what get the folder size. I write small function:
I'm learning to do TDD in practice in small project. I want to create
I want to create a stored procedure (on SQL Server 2005) that fetches a

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.