Numpy int64() function arguments?










0















Not sure why I cannot find this, but what does the following mean?



hashvalue_byte_size = len(bytes(np.int64(42).data))


Going from left to right, I would generically say this describes the length of bytes in np.int64(42).data.



So the byte length is 8.



I think 'np.int64()' means an integer in (-9223372036854775808 to 9223372036854775807) or an unsigned integer in (0 to 18446744073709551615)



Or does the prefix 'np' make int64() something else?



Finally, what does '42' stand for? What does .data mean?










share|improve this question

















  • 1





    See here for differences between built-in integer and numpy integers.

    – onepint16oz
    Nov 14 '18 at 1:48















0















Not sure why I cannot find this, but what does the following mean?



hashvalue_byte_size = len(bytes(np.int64(42).data))


Going from left to right, I would generically say this describes the length of bytes in np.int64(42).data.



So the byte length is 8.



I think 'np.int64()' means an integer in (-9223372036854775808 to 9223372036854775807) or an unsigned integer in (0 to 18446744073709551615)



Or does the prefix 'np' make int64() something else?



Finally, what does '42' stand for? What does .data mean?










share|improve this question

















  • 1





    See here for differences between built-in integer and numpy integers.

    – onepint16oz
    Nov 14 '18 at 1:48













0












0








0








Not sure why I cannot find this, but what does the following mean?



hashvalue_byte_size = len(bytes(np.int64(42).data))


Going from left to right, I would generically say this describes the length of bytes in np.int64(42).data.



So the byte length is 8.



I think 'np.int64()' means an integer in (-9223372036854775808 to 9223372036854775807) or an unsigned integer in (0 to 18446744073709551615)



Or does the prefix 'np' make int64() something else?



Finally, what does '42' stand for? What does .data mean?










share|improve this question














Not sure why I cannot find this, but what does the following mean?



hashvalue_byte_size = len(bytes(np.int64(42).data))


Going from left to right, I would generically say this describes the length of bytes in np.int64(42).data.



So the byte length is 8.



I think 'np.int64()' means an integer in (-9223372036854775808 to 9223372036854775807) or an unsigned integer in (0 to 18446744073709551615)



Or does the prefix 'np' make int64() something else?



Finally, what does '42' stand for? What does .data mean?







python numpy hash byte int64






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 1:27









spacedustpispacedustpi

1109




1109







  • 1





    See here for differences between built-in integer and numpy integers.

    – onepint16oz
    Nov 14 '18 at 1:48












  • 1





    See here for differences between built-in integer and numpy integers.

    – onepint16oz
    Nov 14 '18 at 1:48







1




1





See here for differences between built-in integer and numpy integers.

– onepint16oz
Nov 14 '18 at 1:48





See here for differences between built-in integer and numpy integers.

– onepint16oz
Nov 14 '18 at 1:48












2 Answers
2






active

oldest

votes


















1














It makes most sense to parse an expression like this from the inside out:



In [189]: np.int64(42)
Out[189]: 42
In [190]: type(_)
Out[190]: numpy.int64
In [191]: np.int64(42).data
Out[191]: <memory at 0x7f7dc41a82e8>
In [192]: type(_)
Out[192]: memoryview
In [193]: np.int64(42)
Out[193]: 42
In [194]: type(_)
Out[194]: numpy.int64
In [195]: np.int64(42).data
Out[195]: <memory at 0x7f7dcc05cac8>
In [196]: type(_)
Out[196]: memoryview
In [197]: bytes(np.int64(42).data)
Out[197]: b'*x00x00x00x00x00x00x00'
In [198]: len(_)
Out[198]: 8


It might make more sense to look at a numpy array, with one or more elements:



In [204]: np.array(42)
Out[204]: array(42)
In [205]: _.dtype
Out[205]: dtype('int64')
In [206]: np.array(42).data
Out[206]: <memory at 0x7f7dcc054780>
In [207]: bytes(np.array(42).data)
Out[207]: b'*x00x00x00x00x00x00x00'
In [208]: bytes(np.array([42,43]).data)
Out[208]: b'*x00x00x00x00x00x00x00+x00x00x00x00x00x00x00'


The array object has attributes, and a databuffer. That buffer stores the data, in this case as an 8 byte integer for each element. The bytes(...data) just produces a bytestring representation of that buffer.



Same thing with the tobytes method:



In [209]: np.array([42,43]).tobytes()
Out[209]: b'*x00x00x00x00x00x00x00+x00x00x00x00x00x00x00'





share|improve this answer
































    1














    When you try to decipher expressions like this one, you should not go from left to right, but instead from inside to outside. As you can see below, the first two statements define a numpy.int64 object which takes the value 42. It means that 42 is saved in memory as a 64 bits integer. The next call gives you the memory address of your object. Right after, I think you get the content of your memory address expressed in a language that I do not know. And the last one simply gives you the number of bytes which are allocated at the memory address. Here it is 8, as you have allocated space for a 64 bits integer (1 byte = 8 bits).



    import numpy

    print(numpy.int64(42))
    # 42
    print(type(numpy.int64(42)))
    # <class 'numpy.int64'>
    print(numpy.int64(42).data)
    # <memory at 0x7f5e43221588>
    print(bytes(numpy.int64(42).data))
    # b'*x00x00x00x00x00x00x00'
    print(len(bytes(numpy.int64(42).data)))
    # 8





    share|improve this answer






















      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53291876%2fnumpy-int64-function-arguments%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      It makes most sense to parse an expression like this from the inside out:



      In [189]: np.int64(42)
      Out[189]: 42
      In [190]: type(_)
      Out[190]: numpy.int64
      In [191]: np.int64(42).data
      Out[191]: <memory at 0x7f7dc41a82e8>
      In [192]: type(_)
      Out[192]: memoryview
      In [193]: np.int64(42)
      Out[193]: 42
      In [194]: type(_)
      Out[194]: numpy.int64
      In [195]: np.int64(42).data
      Out[195]: <memory at 0x7f7dcc05cac8>
      In [196]: type(_)
      Out[196]: memoryview
      In [197]: bytes(np.int64(42).data)
      Out[197]: b'*x00x00x00x00x00x00x00'
      In [198]: len(_)
      Out[198]: 8


      It might make more sense to look at a numpy array, with one or more elements:



      In [204]: np.array(42)
      Out[204]: array(42)
      In [205]: _.dtype
      Out[205]: dtype('int64')
      In [206]: np.array(42).data
      Out[206]: <memory at 0x7f7dcc054780>
      In [207]: bytes(np.array(42).data)
      Out[207]: b'*x00x00x00x00x00x00x00'
      In [208]: bytes(np.array([42,43]).data)
      Out[208]: b'*x00x00x00x00x00x00x00+x00x00x00x00x00x00x00'


      The array object has attributes, and a databuffer. That buffer stores the data, in this case as an 8 byte integer for each element. The bytes(...data) just produces a bytestring representation of that buffer.



      Same thing with the tobytes method:



      In [209]: np.array([42,43]).tobytes()
      Out[209]: b'*x00x00x00x00x00x00x00+x00x00x00x00x00x00x00'





      share|improve this answer





























        1














        It makes most sense to parse an expression like this from the inside out:



        In [189]: np.int64(42)
        Out[189]: 42
        In [190]: type(_)
        Out[190]: numpy.int64
        In [191]: np.int64(42).data
        Out[191]: <memory at 0x7f7dc41a82e8>
        In [192]: type(_)
        Out[192]: memoryview
        In [193]: np.int64(42)
        Out[193]: 42
        In [194]: type(_)
        Out[194]: numpy.int64
        In [195]: np.int64(42).data
        Out[195]: <memory at 0x7f7dcc05cac8>
        In [196]: type(_)
        Out[196]: memoryview
        In [197]: bytes(np.int64(42).data)
        Out[197]: b'*x00x00x00x00x00x00x00'
        In [198]: len(_)
        Out[198]: 8


        It might make more sense to look at a numpy array, with one or more elements:



        In [204]: np.array(42)
        Out[204]: array(42)
        In [205]: _.dtype
        Out[205]: dtype('int64')
        In [206]: np.array(42).data
        Out[206]: <memory at 0x7f7dcc054780>
        In [207]: bytes(np.array(42).data)
        Out[207]: b'*x00x00x00x00x00x00x00'
        In [208]: bytes(np.array([42,43]).data)
        Out[208]: b'*x00x00x00x00x00x00x00+x00x00x00x00x00x00x00'


        The array object has attributes, and a databuffer. That buffer stores the data, in this case as an 8 byte integer for each element. The bytes(...data) just produces a bytestring representation of that buffer.



        Same thing with the tobytes method:



        In [209]: np.array([42,43]).tobytes()
        Out[209]: b'*x00x00x00x00x00x00x00+x00x00x00x00x00x00x00'





        share|improve this answer



























          1












          1








          1







          It makes most sense to parse an expression like this from the inside out:



          In [189]: np.int64(42)
          Out[189]: 42
          In [190]: type(_)
          Out[190]: numpy.int64
          In [191]: np.int64(42).data
          Out[191]: <memory at 0x7f7dc41a82e8>
          In [192]: type(_)
          Out[192]: memoryview
          In [193]: np.int64(42)
          Out[193]: 42
          In [194]: type(_)
          Out[194]: numpy.int64
          In [195]: np.int64(42).data
          Out[195]: <memory at 0x7f7dcc05cac8>
          In [196]: type(_)
          Out[196]: memoryview
          In [197]: bytes(np.int64(42).data)
          Out[197]: b'*x00x00x00x00x00x00x00'
          In [198]: len(_)
          Out[198]: 8


          It might make more sense to look at a numpy array, with one or more elements:



          In [204]: np.array(42)
          Out[204]: array(42)
          In [205]: _.dtype
          Out[205]: dtype('int64')
          In [206]: np.array(42).data
          Out[206]: <memory at 0x7f7dcc054780>
          In [207]: bytes(np.array(42).data)
          Out[207]: b'*x00x00x00x00x00x00x00'
          In [208]: bytes(np.array([42,43]).data)
          Out[208]: b'*x00x00x00x00x00x00x00+x00x00x00x00x00x00x00'


          The array object has attributes, and a databuffer. That buffer stores the data, in this case as an 8 byte integer for each element. The bytes(...data) just produces a bytestring representation of that buffer.



          Same thing with the tobytes method:



          In [209]: np.array([42,43]).tobytes()
          Out[209]: b'*x00x00x00x00x00x00x00+x00x00x00x00x00x00x00'





          share|improve this answer















          It makes most sense to parse an expression like this from the inside out:



          In [189]: np.int64(42)
          Out[189]: 42
          In [190]: type(_)
          Out[190]: numpy.int64
          In [191]: np.int64(42).data
          Out[191]: <memory at 0x7f7dc41a82e8>
          In [192]: type(_)
          Out[192]: memoryview
          In [193]: np.int64(42)
          Out[193]: 42
          In [194]: type(_)
          Out[194]: numpy.int64
          In [195]: np.int64(42).data
          Out[195]: <memory at 0x7f7dcc05cac8>
          In [196]: type(_)
          Out[196]: memoryview
          In [197]: bytes(np.int64(42).data)
          Out[197]: b'*x00x00x00x00x00x00x00'
          In [198]: len(_)
          Out[198]: 8


          It might make more sense to look at a numpy array, with one or more elements:



          In [204]: np.array(42)
          Out[204]: array(42)
          In [205]: _.dtype
          Out[205]: dtype('int64')
          In [206]: np.array(42).data
          Out[206]: <memory at 0x7f7dcc054780>
          In [207]: bytes(np.array(42).data)
          Out[207]: b'*x00x00x00x00x00x00x00'
          In [208]: bytes(np.array([42,43]).data)
          Out[208]: b'*x00x00x00x00x00x00x00+x00x00x00x00x00x00x00'


          The array object has attributes, and a databuffer. That buffer stores the data, in this case as an 8 byte integer for each element. The bytes(...data) just produces a bytestring representation of that buffer.



          Same thing with the tobytes method:



          In [209]: np.array([42,43]).tobytes()
          Out[209]: b'*x00x00x00x00x00x00x00+x00x00x00x00x00x00x00'






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 14 '18 at 1:54

























          answered Nov 14 '18 at 1:47









          hpauljhpaulj

          112k780148




          112k780148























              1














              When you try to decipher expressions like this one, you should not go from left to right, but instead from inside to outside. As you can see below, the first two statements define a numpy.int64 object which takes the value 42. It means that 42 is saved in memory as a 64 bits integer. The next call gives you the memory address of your object. Right after, I think you get the content of your memory address expressed in a language that I do not know. And the last one simply gives you the number of bytes which are allocated at the memory address. Here it is 8, as you have allocated space for a 64 bits integer (1 byte = 8 bits).



              import numpy

              print(numpy.int64(42))
              # 42
              print(type(numpy.int64(42)))
              # <class 'numpy.int64'>
              print(numpy.int64(42).data)
              # <memory at 0x7f5e43221588>
              print(bytes(numpy.int64(42).data))
              # b'*x00x00x00x00x00x00x00'
              print(len(bytes(numpy.int64(42).data)))
              # 8





              share|improve this answer



























                1














                When you try to decipher expressions like this one, you should not go from left to right, but instead from inside to outside. As you can see below, the first two statements define a numpy.int64 object which takes the value 42. It means that 42 is saved in memory as a 64 bits integer. The next call gives you the memory address of your object. Right after, I think you get the content of your memory address expressed in a language that I do not know. And the last one simply gives you the number of bytes which are allocated at the memory address. Here it is 8, as you have allocated space for a 64 bits integer (1 byte = 8 bits).



                import numpy

                print(numpy.int64(42))
                # 42
                print(type(numpy.int64(42)))
                # <class 'numpy.int64'>
                print(numpy.int64(42).data)
                # <memory at 0x7f5e43221588>
                print(bytes(numpy.int64(42).data))
                # b'*x00x00x00x00x00x00x00'
                print(len(bytes(numpy.int64(42).data)))
                # 8





                share|improve this answer

























                  1












                  1








                  1







                  When you try to decipher expressions like this one, you should not go from left to right, but instead from inside to outside. As you can see below, the first two statements define a numpy.int64 object which takes the value 42. It means that 42 is saved in memory as a 64 bits integer. The next call gives you the memory address of your object. Right after, I think you get the content of your memory address expressed in a language that I do not know. And the last one simply gives you the number of bytes which are allocated at the memory address. Here it is 8, as you have allocated space for a 64 bits integer (1 byte = 8 bits).



                  import numpy

                  print(numpy.int64(42))
                  # 42
                  print(type(numpy.int64(42)))
                  # <class 'numpy.int64'>
                  print(numpy.int64(42).data)
                  # <memory at 0x7f5e43221588>
                  print(bytes(numpy.int64(42).data))
                  # b'*x00x00x00x00x00x00x00'
                  print(len(bytes(numpy.int64(42).data)))
                  # 8





                  share|improve this answer













                  When you try to decipher expressions like this one, you should not go from left to right, but instead from inside to outside. As you can see below, the first two statements define a numpy.int64 object which takes the value 42. It means that 42 is saved in memory as a 64 bits integer. The next call gives you the memory address of your object. Right after, I think you get the content of your memory address expressed in a language that I do not know. And the last one simply gives you the number of bytes which are allocated at the memory address. Here it is 8, as you have allocated space for a 64 bits integer (1 byte = 8 bits).



                  import numpy

                  print(numpy.int64(42))
                  # 42
                  print(type(numpy.int64(42)))
                  # <class 'numpy.int64'>
                  print(numpy.int64(42).data)
                  # <memory at 0x7f5e43221588>
                  print(bytes(numpy.int64(42).data))
                  # b'*x00x00x00x00x00x00x00'
                  print(len(bytes(numpy.int64(42).data)))
                  # 8






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 14 '18 at 1:50









                  Patol75Patol75

                  6236




                  6236



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53291876%2fnumpy-int64-function-arguments%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      這個網誌中的熱門文章

                      Barbados

                      How to read a connectionString WITH PROVIDER in .NET Core?

                      Node.js Script on GitHub Pages or Amazon S3