class_docstr: An input connection.
  
      
docstr: Make a new source from a memory object.
  
  Make a new source that is attached to the memory object. For example::
  
      source = pyvips.Source.new_from_memory("myfile.jpg")
  
  You can pass this source to (for example) :meth:`new_from_source`.
  
  The memory object can be anything that supports the Python buffer or
  memoryview protocol.
docstr_tok: ["Make","a","new","source","from","a","memory","object",".","Make","a","new","source","that","is","attached","to","the","memory","object",".","For","example",":",":","source","=","pyvips.Source.new_from_memory","(","``","myfile.jpg","''",")","You","can","pass","this","source","to","(","for","example",")",":","meth",":","`","new_from_source","`",".","The","memory","object","can","be","anything","that","supports","the","Python","buffer","or","memoryview","protocol","."]
code: def new_from_memory(data):
      """Make a new source from a memory object.
  
      Make a new source that is attached to the memory object. For example::
  
          source = pyvips.Source.new_from_memory("myfile.jpg")
  
      You can pass this source to (for example) :meth:`new_from_source`.
  
      The memory object can be anything that supports the Python buffer or
      memoryview protocol.
  
      """
  
      # logger.debug('VipsSource.new_from_memory:')
  
      # py3:
      #   - memoryview has .nbytes for number of bytes in object
      #   - len() returns number of elements in top array
      # py2:
      #   - buffer has no nbytes member
      #   - but len() gives number of bytes in object
      start = ffi.from_buffer(data)
      nbytes = data.nbytes if hasattr(data, "nbytes") else len(data)
  
      pointer = vips_lib.vips_source_new_from_memory(start, nbytes)
      if pointer == ffi.NULL:
          raise Error("can't create input source from memory")
  
      source = Source(pointer)
  
      # keep a secret reference to the input data to make sure it's not GCed
      source._references = [data]
  
      return source
  
file_path: pyvips/pyvips/vsource.py
imports: from __future__ import division
  import logging
  import pyvips
  from pyvips import ffi, vips_lib, Error, _to_bytes
label_desc: Use image node_id 4 for calling the Source obj's underlying member method code with example usage: obj.new_from_memory(data) and returns: source